Group Group Group Group Group Group Group Group Group Forums

UISplitViewController Tutorial: Getting Started

Learn the basics of UISplitViewController and get the very common master-detail pattern working in your apps!

This is a companion discussion topic for the original entry at

First of all, thank you for this tutorial!

I believe that i found a typo in the code>
if let detailViewController = self.delegate as? DetailViewController { splitViewController?.showDetailViewController(DetailViewController, sender: nil) }

Shouldn’t it be showDetailViewController(detailViewController, sender: nil) instead?
DetailViewController vs detailViewController

There is a logic bug in the code, calling the view controllers in the app delegate does not guarantee that the view hierarchy is being loaded since no view has been referenced. So on my Xcode 7.3/iOS 9.3 the detail page does not refresh correctly unless I add


to reference the view and thus load it before = firstMonster

Thanks for this great tutorial. I have a question about having the app launch into the master view controller when on iPhone. I can get this working by setting the split view’s delegate and then calling the delegate method

splitViewController(splitViewController: UISplitViewController, collapseSecondaryViewController secondaryViewController: UIViewController, ontoPrimaryViewController primaryViewController: UIViewController)

to return true

However when I do that I get the following error and the detail view controller is not showing the correct information:

Unbalanced calls to begin/end appearance transitions for <UINavigationController: 0x7fc71b83e000>.

Is there any way to fix this?

Thank you!

Just a heads up that this project won’t compile after recent Swift changes. In particular, the init method of the MasterViewController fails with an error of "A non-failable initializer cannot chain to failable initializer ‘init(coder:)’ written with ‘init?.’


Found a couple conflicts with the newer swift xcode release in that you need to write the init coder part as ‘required init?’ with a question mark or else you get an error and possibly add an exclamation mark somewhere in the Tableview DidSelectRow part. The other thing I noticed was that the constraints need work for when the ipad is in portrait mode the Tableview on the left blocks the detail view content from being displayed. Good tutorial though.


Anyone having any luck using this in Swift? I can get it to compile but the Detail view does nto update. I even downloading the completed project and tried to update the Syntax and the same thing happened.

Loading the final project into xcode8 and converting to swift3 will generate a couple of build errors on the process.

Don’t be scared by that, clear the project and try to run it.

It will generate a new error on super.init call in the init of MastViewController. Change it to:

super.init(coder: aDecoder)!

And the project will run now.

same problem. Any solution …

i have an other problem: when the app start on iPhone it be shown the detail view and not the master view with the list of monster.

I’ve try to use some delegate method but nothing.

any solutions?

How would this setup work if you needed to reuse the UISplitViewController elsewhere in the application? By this I mean there could be need to load a different master view controller with associated (perhaps multiple) detail view controllers.

In my opinion - and I could be wrong - it would be better to have the master view controller instantiate and push 1 or more view controllers into the detail view controller.

This way you can create delegates in the detail view controller(s) (as opposed to doing it in the master) and make the master implement these delegates to handle requests from detail view controllers. In this setup, the master view controller plays a central role in linking to one or more detail view controllers and it becomes easier to conditionally select what detail view controller to display. Let me know your thoughts on this.

Is possible change navigation controller width?

you mean height, isn’t it?

hope this helps you:

This tutorial is more than six months old so questions are no longer supported at the moment for it. We will update it as soon as possible. Thank you! :]