Split view in portrait mode!

前端 未结 6 1567
梦毁少年i
梦毁少年i 2021-01-11 10:57

Apple provide the split view only for landscape but not for the portrait mode. Is there any way to achieve the splitview in portrait mode also?

[splitViewCo         


        
6条回答
  •  难免孤独
    2021-01-11 11:21

    update in iOS 8 xcode 6+

    if let splitVCExists = self.splitViewController{
            splitVCExists.preferredDisplayMode = UISplitViewControllerDisplayMode.AllVisible
        }    
    

    doc: https://developer.apple.com/library/ios/documentation/UIKit/Reference/UISplitViewController_class/index.html#//apple_ref/occ/instp/UISplitViewController/preferredDisplayMode

    One thing I did notice is that it will try to layout the splitviewcontroller based on the preferredDisplayMode as long as there is enough space. otherwise it will choose the display mode to fit the content right. I have used it and it lays the VCs out how I want in both portrait and landscape.

提交回复
热议问题