UISplitViewController in portrait on iPhone shows

2019-01-03 11:40发布

I am using a Universal Storyboard in Xcode 6, targeting iOS 7 and above. I've implemented a UISplitViewController which is now natively supported on iPhone running iOS 8, and Xcode will automatically backport it for iOS 7. It's working really well, except when you launch the app on iPhone in portrait running iOS 8, the split view's detail view controller is displayed when I expected to first see the master view controller. I believed this was a bug with iOS 8 because when you run the app on iOS 7, it correctly shows the master view controller. But iOS 8 is now GM and this is still occurring. How can I set it up so that when the split view controller is going to be collapsed (only one view controller displayed on screen), when the split view controller is displayed it shows the master view controller not the detail?

I've created this split view controller in Interface Builder. The split view controller is the first view controller within a tab bar controller. Both the master and the detail VCs are navigation controllers with table view controllers embedded inside.

13条回答
smile是对你的礼貌
2楼-- · 2019-01-03 12:28

If you don't have default values to show in detail view controller, you could just simply delete the default segue between the SplitViewController and your detail UIViewController in the story board. This will make it always goes into Master View Controller first.

The side effect of this is that instead of seeing two view in landscape, you will see one view in full size in SplitViewController until Show Detail Segue in master view controller fired.

查看更多
登录 后发表回答