views:

60

answers:

1

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.navigationBar.barStyle = UIBarStyleDefault;  
[self.parentViewController presentModalViewController:modalNavController animated:YES]; 
[modalNavController release];
A: 

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.

Rudiger
self is subclassing UIViewController. I decided to just add the UIButton to the subview from the DetailViewController because I couldnt figure out how to do it any other way. Do you mean I ought to try [self.parentViewController push...] ?? Apparently, parentViewController is returning nil. Could you direct me towards a resource where I could learn a little more about the "delegate method" of implementing this? I just want to do this properly because all the BS hacks ive tried have done nothing but cause me headaches. Thanks!
culov
you should probably just use self, not self.something. To look at the delegate method implementation have a look at lecture 11 of the stanford iPhone development course (May 6, 2009) available from iTunesU. Like I said you don't really need it but its the "correct" way of doing it, will give you a better understanding of the SDK with things like TableViews and so forth, and once you fully understand it you can do some really good things with it.
Rudiger
oh and yes, I meant to say try [self.parentViewController push to see if it works. I think it should be just self as you are calling predefined method of UIViewController
Rudiger
I'll definitely take a look at that lecture. I'm familiar with using delegates in table views and tab bars (this isnt my first iphone app), but I couldnt really see how they could help me in this situation. I'll watch the video and hopefully learn a thing or two ;)
culov
Using delegates are easy, this is creating a delegates though.
Rudiger