我正在尝试为我的应用中的网站创建类似自己的"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];
我的问题是如何让我的后退按钮再次关闭模态视图?或者我该如何设置动作?谢谢你的帮忙
如果您在此之后使用此代码,那么它将起作用.
navBar.topItem.leftBarButtonItem =[UIBarButtonItem alloc]initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:self action:@selector(backButtonItemToDismissModal)]; -(void)backButtonItemToDismissModal{ [self dismissModalViewControllerAnimated:YES]; }