相关疑难解决方法(0)

iOS 8 presentationController确定是否真的是popover

我正在使用iOS 8的新自适应"Present As Popover"功能.我在StoryBoard中连接了一个简单的segue来进行演示.它适用于iPhone 6 Plus,因为它将视图显示为弹出窗口,而在iPhone 4s上则显示为全屏视图(工作表样式).

问题是当显示为全屏视图时,我需要在视图中添加"完成"按钮,以便可以调用dismissViewControllerAnimated.当它显示为弹出窗口时,我不想显示"完成"按钮.

在此输入图像描述

我试着查看presentationController和popoverPresentationController的属性,我什么也没发现,它告诉我它是否实际显示为弹出框.

NSLog( @"View loaded %lx", (long)self.presentationController.adaptivePresentationStyle );          // UIModalPresentationFullScreen
NSLog( @"View loaded %lx", (long)self.presentationController.presentationStyle );                  // UIModalPresentationPopover
NSLog( @"View loaded %lx", (long)self.popoverPresentationController.adaptivePresentationStyle );   // UIModalPresentationFullScreen
NSLog( @"View loaded %lx", (long)self.popoverPresentationController.presentationStyle );           // UIModalPresentationPopover
Run Code Online (Sandbox Code Playgroud)

adaptivePresentationStyle始终返回UIModalPresentationFullScreen,而presentationStyle始终返回UIModalPresentationPopover

在查看UITraitCollection时,我确实发现了一个名为"_UITraitNameInteractionModel"的特征,当它实际显示为Popover时,它只被设置为1.但是,Apple不通过popoverPresentationController的traitCollection直接访问该特征.

uipopovercontroller ios8 adaptive-layout

16
推荐指数
2
解决办法
5469
查看次数