开发者

UINavigationController issue

开发者 https://www.devze.com 2023-04-06 03:22 出处:网络
I am programming a iPad application. In my UIViewController class, I am processing a button tapping through which I am displaying another view (UIWebView), by pushing it in UINavigationController.

I am programming a iPad application. In my UIViewController class, I am processing a button tapping through which I am displaying another view (UIWebView), by pushing it in UINavigationController.

The problem is though my view is getting pushed into UINavigationController and getting displayed, I am unable to see the "back" button in the Navigation bar.

I have not included the UINavigationController class in my AppDelegate, as I am trying to directly use UINavigationController from within my method. Below is my button tap processing code:

NSString *url = [imageDict valueForKey:strName];
UINavigationController *navigation = [[UINavigationController alloc]init];
[navigation setNavigationBarHidden:NO];
[self.view addSubview:navigation.view];

CarouselWebView *carouselWebView = [[CarouselWebView alloc] initWithNibName:@"CarouselWebView" bundle:nil];
carouselWebView.urlString = url;
carouselWebView.title=@"Carousel Web View";
[navigation pushViewController:carouselWebView animated:YES];
[carouselWebView release];

Please let me know what I am doing wrong here.

T开发者_运维技巧hanks,


You will not get the Back button automatically, because your app believes that carouselWebView is the first view in the navigation controller's stack.

There are two ways you can handle this:

  1. Initialize the navigation controller to push the view before carouselWebView first. This would not show any buttons on the navigation bar in the first view, but would make the Back button show up when pushing a view on top of this initial view.
  2. You can manually add a Back button to carouselWebView, and attach to it a method that dismisses that view, since you will not have it automatically set up by the navigation controller. I do not believe you can manually set it up as the 'arrow-shaped' button, but you can show the default button labeled with 'Back' text.


in the first view set the title and it should work

self.title = @"First view"
0

精彩评论

暂无评论...
验证码 换一张
取 消