导航栏“返回”关闭模态视图的按钮
我正在尝试为我的应用程序中的网站创建类似自己的“adBanner”的内容。
横幅是一个带有图像的按钮,实际上是横幅图形。
[_adBanner setBackgroundImage:[UIImage imageNamed:@"test_banner.png"] forState:UIControlStateNormal];
_adBanner.opaque = YES;
[self.view addSubview:_adBanner];
[(UIButton*) _adBanner addTarget:self action:@selector(showWebView:) forControlEvents:UIControlEventTouchUpInside];
[_adBanner release];
翻转视图的函数
- (IBAction)showWebView:(id)sender {
XLog ("Button Clicked");
WebViewController *_webViewController = [[WebViewController alloc] init];
_webViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:_webViewController animated:YES];
}
这是我在 _webViewController 中
编写了一个导航栏
我想显示一个带有 url 的 UIWebView 首先,我用标题WebViewController.m
// Setting Navigation Bar
CGRect navBarRect = CGRectMake(0.0f, 0.0f, 320.0f, 44.0f);
navBar = [ [ UINavigationBar alloc ] initWithFrame: CGRectMake(navBarRect.origin.x, navBarRect.origin.y, navBarRect.size.width, 45.0f)];
[ navBar setDelegate: self.view ];
[ self.view addSubview: navBar ];
[ navBar release];
// Setting TitleString
NSString* adClientTitleString = [ [ NSString alloc] initWithString:@"Client" ];
// Setting Title
[ navBar pushNavigationItem: [ [ UINavigationItem alloc ] initWithTitle:adClientTitleString ] ];
[ navBar setDelegate: self];
:现在我创建了一个后退按钮
[ navBar showButtonsWithLeftTitle: @"Zurück" rightTitle:nil leftBack: YES];
我的问题是如何制作我的后退按钮再次关闭模态视图? 或者我该如何设置动作?谢谢你的帮助
I´m trying to create something like an own "adBanner" for a website in my app.
The Banner is a Button with an image, which is actually the banner graphic.
[_adBanner setBackgroundImage:[UIImage imageNamed:@"test_banner.png"] forState:UIControlStateNormal];
_adBanner.opaque = YES;
[self.view addSubview:_adBanner];
[(UIButton*) _adBanner addTarget:self action:@selector(showWebView:) forControlEvents:UIControlEventTouchUpInside];
[_adBanner release];
here is my function for flipping the view
- (IBAction)showWebView:(id)sender {
XLog ("Button Clicked");
WebViewController *_webViewController = [[WebViewController alloc] init];
_webViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:_webViewController animated:YES];
}
in my _webViewController I want to show a UIWebView with an url
First I coded a Navigation Bar with Title
WebViewController.m :
// Setting Navigation Bar
CGRect navBarRect = CGRectMake(0.0f, 0.0f, 320.0f, 44.0f);
navBar = [ [ UINavigationBar alloc ] initWithFrame: CGRectMake(navBarRect.origin.x, navBarRect.origin.y, navBarRect.size.width, 45.0f)];
[ navBar setDelegate: self.view ];
[ self.view addSubview: navBar ];
[ navBar release];
// Setting TitleString
NSString* adClientTitleString = [ [ NSString alloc] initWithString:@"Client" ];
// Setting Title
[ navBar pushNavigationItem: [ [ UINavigationItem alloc ] initWithTitle:adClientTitleString ] ];
[ navBar setDelegate: self];
and now I created a back Button
[ navBar showButtonsWithLeftTitle: @"Zurück" rightTitle:nil leftBack: YES];
My question Is How I can make my back Button to dismiss the Modal View again ?
Or how can I set the action ?? Thank You for helping
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您之后使用此代码,那么它将起作用。
If you use this code after that then it will work.
如果你想使用模态视图控制器,那么你可以使用 WebViewController 类的missModalViewController 方法来关闭它。
另一种方法是使用 UINavigationController。您可以检查示例控制器。
要使左按钮工作,您还应该实现
- (void)navigationBar:(UINavigationBar*)navbar buttonClicked:(int)button
方法。
If you want to use modal view controller, then you can dismiss it with dismissModalViewController method of a WebViewController class.
Other way is to use UINavigationController. You may check examples for this controller.
To make left button work you should also implement
- (void)navigationBar:(UINavigationBar*)navbar buttonClicked:(int)button
method.