0
votes

I would like to implement a UISplitViewController that runs on iPad and iPhone. When running on iPhone I only want one view controller visible on screen at a time, so when the user taps on a cell in the master view controller it should push to reveal the detail view controller.

I have dragged out a UISplitViewController in Interface Builder and have got it working great on iPad. When I tap a cell, it updates the detail view controller's information via a protocol. It simply calls the method on the delegate and passes in the appropriate information, and that delegate method just takes in the passed data and reloads the table. Because both are on screen at the same time it works great.

But when I run the app on iPhone, when I select a row, the methods are still obviously called but the detail view controller doesn't get pushed on screen. It seems as if nothing happens when you tap a cell.

I was under the impression this should occur automatically when using a split view controller on iPhone, but perhaps I need to do a little work to make it behave as expected.

What much I do to push the detail view controller onto the navigation stack when the user selects a row in the master view controller when running on iPhone?

Additionally, is it possible to make this compatible with iOS 7, or will I need to do it the old way on that OS - when the user selects the row, perform a push segue to reveal the second view controller?

1

1 Answers

-1
votes

According to apple docs, you can't use UISplitViewController on the iphone.

The UISplitViewController class is a container view controller that manages the presentation of two side-by-side view controllers. You use this class to implement a master-detail interface, in which the left-side view controller presents a list of items and the right-side presents details of the selected item. Split view controllers are for use exclusively on iPad devices. Attempting to create one on other devices results in an exception

What I do is check if it is an iPad or not, and work accordingly. You could change the delegates for example.

You can set the delegate to self when it is iphone, and use the same method that used to change information in the detail view, make a push and show the data like that.