我正在从 UISplitViewController
的主面板中呈现模态视图和操作表。 iOS 9.3
1) 如果我在 iPad 处于纵向模式时显示 View 并将 iPad 旋转到横向,则屏幕不会旋转。
2) 但如果我在 iPad 处于横向模式时显示 View 并将 iPad 旋转到纵向,则屏幕正在旋转。
如何实现旋转?
最佳答案
有两种方法可以解决这个问题:
从主面板呈现模态视图并不理想,但您应该从 UISplitViewController 本身进行。
splitViewController.preferredDisplayMode =UISplitViewControllerDisplayModeAllVisible; // For displaying the master panel always as is in the screen shot in the Question modalViewController.modalPresentationStyle = UIModalPresentationFormSheet; // For displaying the modalViewController in form sheet style [splitViewController presentViewController:modalViewController animated:TRUE completion:nil]; // Note: modalViewController is presented from UISplitViewController and not from master panel of split view
在纵向模式下,溢出 View 的主面板显示在弹出窗口中,因此设备旋转更改必须通过 popovercontroller。我猜这时链条断了。所以,要解决这个问题调用
[spliVC setPreferredDisplayMode:UISplitViewControllerDisplayModePrimaryHidden];
在调用模态表示转场之前(来自prepareForSegue
)。我不确定代表是否使用这种方法。
编辑:
我还观察到,如果 Split View处于 UISplitViewControllerDisplayModeAllVisible
模式,那么即使从主面板呈现模态 vc(比方说通过 Storyboard 中的简单模态转场)也不会出现旋转问题。我已经在 iOS 9.3 模拟器中确认了这一点。
关于ios - 从纵向旋转到横向时,从 UISplitViewController 的主面板呈现的 View 不旋转 (iPad),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38634092/