objective-cios7uimodalpresentationstyle

iOS 7 overrides CurrentContext modal presentation


I have a pretty standard view hierarchy, mainly with a UITabBarController containing several UINavigationControllers.

I'm creating a new UINavigationController and presenting it modally from within one of the tabs.

I want it to show with UIModalPresentationCurrentContext, so I'm setting it like so:

[newNavCon setModalPresentationStyle:UIModalPresentationCurrentContext];

And then, I present it like this:

[oldNavCon presentViewController:newNavCon animated:YES completion:nil];

But when it gets presented, it is full screen, not the current context that I set.

When I look at the breakpoints, the modal presentation style on newNavCon is changed to UIModalPresentationFullScreen immediately after presentViewController.

The thing that really confuses me is that this behavior happens only on iOS7. It works exactly as expected on iOS 8-10.

Why is this happening? Is there some specific quirk that I don't know about on iOS7? Why would the presentation style get overridden like this?

EDIT: To clarify, here's the view hierarchy I'm working with:


Solution

  • I'm guessing you're testing on an iPhone device or simulator. In iOS 7 and before, UIModalPresentationCurrentContext was an iPad-only feature.