简体   繁体   English

在两个不同的UIPresentationController的之间适应

[英]Adapting between two different UIPresentationController's

I would like to adapt between two different UIPresentationController , according to the current trait collection. 我想根据当前特征集在两个不同的UIPresentationController之间进行调整。 For example, the two controllers could be UIPopoverPresentationController for any traits and a custom UIPresentationController for compact horizontal traits (eg iPhone). 例如,这两个控制器可以是UIPopoverPresentationController任何性状和定制UIPresentationController紧凑水平性状(例如iPhone)。

Unfortunately this doesn't seem possible in the latest iOS 8. In particular: 不幸的是,这在最新的iOS 8中似乎无法实现。特别是:

  • You can set a UIAdaptivePresentationControllerDelegate to swap out the presentation style, but only permits the standard full screen presentation controller. 您可以设置UIAdaptivePresentationControllerDelegate换出演示文稿样式,但仅允许标准的全屏演示文稿控制器。

  • 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. 您可以在呈现视图控制器之前选择要使用的呈现控制器,但是当特质集合发生更改(例如在iPad多任务处理或方向更改中)呈现后,这实际上并不会适应。

A couple of different attempts at a solution: Tumblr , Irace 解决方案的几种不同尝试: TumblrIrace

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. 对于自定义过渡,您只需在从viewControllerForAdaptivePresentationStyle返回的视图控制器上设置过渡委托类,在本例中, viewControllerForAdaptivePresentationStyle是一个导航控制器,具有透明的变暗视图,其表格位于底部,右侧导航项位于完成按钮。 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. 如果您希望自己运行该行为,请运行Maps并点击右下角的“信息”按钮,然后在iPhone和iPad上尝试一下,我已完全复制了该行为。 Here are screenshots of compact and regular: 这是紧凑和常规的屏幕截图: 在此处输入图片说明 在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM