I have a pretty standard view hierarchy, mainly with a UITabBarController
containing several UINavigationController
s.
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:
UIViewController
(as a container, fullscreen)UITabBarController
(not fullscreen, as controlled by the container)
definesPresentationContext
UINavigationController
(as tab root, presents the modal window)
definesPresentationContext
UINavigationController
(presented modally by the above UIViewController
)
modalPresentationStyle
= UIModalPresentationCurrentContext
UIViewController
I'm guessing you're testing on an iPhone device or simulator. In iOS 7 and before, UIModalPresentationCurrentContext
was an iPad-only feature.