It also knocks down the iPad. Use Multitasking to resize the application to a compact width (for example, 1/3 of the screen), click the "Launch Detail" button, and then change it to its normal width.
When you are in compact width, the split view controller will crash. This means that it no longer displays the individual primary and secondary view controllers at the same time; instead, it "collapses" them into a single view controller hierarchy. When this happens in this environment, you often need your help to act wisely. The default behavior works well when your primary and secondary view controllers are UINavigationControllers, but not in other cases.
(In your application, your main element is the UITabBarController, and after you “Run the part” once, the secondary is also the UITabBarController. You may want to review this design because it complicates the work. Keep reading.)
Your Launch Detail application executes a Show Detail segue, which effectively calls this method in the UISplitViewController:
public func showDetailViewController(vc: UIViewController, sender: AnyObject?)
Note the comment in the title:
Under “master view controller or detail view controller”, this means that the view manager, which in your case is a UITabBarController, is currently displayed. But the UITabBarController does not implement anything for showViewController() , because it does not have enough information - where would it display the view controller? Will she add a new tab or replace the old one or what?
So, as a result, you get this backup, full-screen presentation. I doubt that you really need this user.
Later, when the size changes to Normal, and the split view controller expands, it gets confused in the presentation and eventually works. (See what I mean that the defaults are not very good?)
One way to fix this is to implement the delegate method to handle showDetail . When the width is Compact, explicitly find the view controller on which you want to place the new view controller, and do it. I think you probably want to click on the navigation controller in the first tab:
func splitViewController(splitViewController: UISplitViewController, showDetailViewController vc: UIViewController, sender: AnyObject?) -> Bool { if splitViewController.traitCollection.horizontalSizeClass == .Compact {
If you do this, you will also want to implement this delegate method. When the size is changed to "Normal", you will want to handle the "expand" by pulling this view controller from the same navigation controller, and then return it:
optional public func splitViewController( splitViewController: UISplitViewController separateSecondaryViewControllerFromPrimaryViewController primaryViewController: UIViewController) -> UIViewController?