首页 文章

UISplitViewController主面板显示的视图在从纵向旋转到横向时不旋转(iPad)

提问于
浏览
10

我将在 UISplitViewController 的主面板上展示模态视图和操作表 . iOS 9.3

1) 如果我在iPad处于纵向模式时显示视图并将iPad旋转到横向,则屏幕不会旋转 .
enter image description here

2)但是如果我在iPad处于横向模式时呈现视图并将iPad旋转为纵向,则屏幕正在旋转 .

我怎样才能实现轮换?

1 回答

  • 1

    解决此问题有两种解决方案:

    • 从主面板呈现模态视图并不理想,但您应该从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
    
    • 溢出视图的主面板在纵向模式下显示在弹出窗口中,因此设备旋转更改必须通过popovercontroller . 我猜这个点上的连锁店 . 所以,要解决问题调用
    [spliVC setPreferredDisplayMode:UISplitViewControllerDisplayModePrimaryHidden];
    

    在调用模态表示segue之前(来自 prepareForSegue ) . 我不确定代表们是否采用这种方法 .

    EDIT: 我还观察到,如果拆分视图处于 UISplitViewControllerDisplayModeAllVisible 模式,那么即使从主面板呈现模态vc(假设通过故事板中的简单模态segue)也不会给出旋转问题 . 我已经在iOS 9.3模拟器中证实了这一点 .

相关问题