I would like to adapt between two different UIPresentationController
, according to the current trait collection. For example, the two controllers could be UIPopoverPresentationController
for any traits and a custom UIPresentationController
for compact horizontal traits (eg iPhone).
Unfortunately this doesn't seem possible in the latest iOS 8. In particular:
You can set a UIAdaptivePresentationControllerDelegate
to swap out the presentation style, but only permits the standard full screen presentation controller.
You can choose which presentation controller to use just before presenting the view controller, but this doesn't actually adapt after presenting when the traits collection changes eg in iPad multitasking or orientation change.
A couple of different attempts at a solution: Tumblr , Irace
Any suggestions?
To assume you require two presentation controllers for adaptation is a false assumption.
There is only one presentation controller and you have to adapt the view and/or the transition using the delegate methods. For the custom transition you simply set a transition delegate class on the view controller you return from viewControllerForAdaptivePresentationStyle
which in my case was a navigation controller with a transparent dimmed view with table at bottom and done button in the right nav item. My custom transition moves the table up from the bottom, while dimming and resizing the dimmed view, and fading in the nav bar. If you would like to see the behaviour yourself run Maps and tap the bottom right info button and try it on iPhone and iPad, I've copied that exactly. Here are screenshots of compact and regular:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.