4
votes

I have my app that is below a UINavigationController and therefore below a UINavigationBar. I want to present a Modal View Controller on top of this UINavigationBar because the controller I wrote doesn't make sense if it's below it (that is, I want to hide the navigation bar when showing this view controller).

Presenting it with this code:

    ukc = [[UnlockKeyboardViewController alloc] init];
    [self presentModalViewController:ukc animated:NO];

Cause the Modal view controller to be below the UINavigationBar. That UINavigationBar shouldn't show up when I show this modal view. How can I go around that?

PS: This is a jailbreak app, so there's no Interface Builder.

2

2 Answers

9
votes
[self.navigationController presentModalViewController:ukc animated:NO];
0
votes

Extra info upon working with a related issue:

note173's answer works with animated:YES too. The user will see ukc's view slide up over the nav stack.

And if you subsequently need to dismiss ukc and return to self's view, do this:

        [self.navigationController dismissModalViewControllerAnimated:NO];
        [self.navigationController dismissModalViewControllerAnimated:YES]; 

The first call dismisses ukc. The second call dismisses the nav controller. What the user sees is ukc's view sliding down to reveal self's view, with a glimpse of the navigation stack behind it.

So what you have here is a way of switching directly from the nav stack to some other regular view controller, and then back to a base view controller, all with animations that make sequential sense.

(If your aim was to switch back and forth between the nav stack and ukc, you would dismiss ukc with one call -- self.navigationController dismissModalViewControllerAnimated:YES]; which would slide ukc's view down to reveal the nav stack.)

Note that these methods are deprecated in iOS 5. I assume presentViewController and dismissViewControllerAnimated would do the same thing, but I haven't tested them.