开发者

How can I display a view controller modally, using the parent's navigation controller?

I'm implementing a UITabBar in the middle of my navigation stack without UITabBarController. The UITabBar is in the DetailViewController which delegate a portion of the screen to the view controller associated with the selected tab element. Inside one of view controller's thats displayed via tab bar selection, there's a UIButton which needs to display a view modally. I tried [self presentModalViewController:modalNavController animated:YES];, but the new navigation bar was hidden underneath the nav bar of the parent controller, DetailViewController. So what I think I need to do is use the parent's navigation controller to present the view modally so that the new nav bar is ON TOP of the DetailViewController nav bar.

I know its possible because I have an ad in the DetailViewController, and tapping the add gives me the desired result, but I haven't been able to incorporate that code. I could also probably display the UIButton from the DetailViewController rather than the subView, but I need to use this pattern a few times, so I'd rather not have to work with an unorthodox hack like that.

THANKS!

EDIT

I have already tried adding the new view to a navigation controller and then presenting the navigation controller like so:

WriteReviewController *newReview = [[WriteReviewController alloc] initWithNibName:@"WriteReviewController" bundle:nil];
UINavigationController *modalNavController = [[UINavigationController alloc] initWithRootViewController:newReview];
// This is intended to be presented in another view controller class
modalNavController.navig开发者_开发百科ationBar.barStyle = UIBarStyleDefault;  
[self.parentViewController presentModalViewController:modalNavController animated:YES]; 
[modalNavController release];


Is self subclassing UIViewController or something else? I have successfully done a view with a nav controller this way although I don't usually do it with a nib. See if you have success with pushing the view first and then try to presentModalView.

Also I recommend using the delegate method of implementing this. Although not necessary for what you are doing you will find you will run into less problems later and is probably considered the "correct" way of doing things.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜