I have a master-detail application (I created it using the Xcode template, and then I modified it a bit), and I'm trying to set the preferredDisplayMode property of UISplitViewController to obtain this behavior:
UISplitViewControllerDisplayMode.PrimaryOverlay: The primary view controller is layered on top of the secondary view controller, leaving the secondary view controller partially visible.
So the master view controller should initially be on top of the detail view controller, and it should be possible to dismiss it. I change this property in application:didFinishLaunchingWithOptions:, that's the full code:
// Inside application:didFinishLaunchingWithOptions:
// Override point for customization after application launch.
let rootViewController = window!.rootViewController as! UINavigationController
// The root view controller is a navigation controller that contains the split view controller
let splitViewController = rootViewController.viewControllers[0] as! UISplitViewController
let navigationController = splitViewController.viewControllers[splitViewController.viewControllers.count-1] as! UINavigationController
navigationController.topViewController.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem()
splitViewController.delegate = self
splitViewController.preferredPrimaryColumnWidthFraction = 0.4
splitViewController.maximumPrimaryColumnWidth = 600
splitViewController.preferredDisplayMode = .PrimaryOverlay
return true
I have two problems: first, that's not the behavior that I obtain. The master view controller is hidden when the application launches, and if I click on the left bar button item to show the master, it rapidly appears and then disappears again. If I click it another time it appears without disappearing.
Second, I get a warning in the console:
2015-06-30 12:06:26.613 Presidents[29557:857547] Unbalanced calls to begin/end appearance transitions for <UINavigationController: 0x7b8be610>.
But I have no transitions in my code.
PS: It's from the book "Beginning Phone Development with Swift" by D. Mark, J. Nutting, K. Topley, F. Olsson, J. LaMarche, chapter 11.