15

Trying to make storyboard based application for iPad. In it I need to transition from start screen (UIViewController) to main screen (UISplitViewController) and then to full-screen view (again UIViewController).

I saw a number of discussions on the web (at least several - on stackoverflow), stating that UISplitViewController can't be used in Storyboard based application any other way than being RootViewController. Some threads contain workarounds and there's also alternative splitview (https://github.com/mattgemmell/MGSplitViewController) to cope with this.

But what I can't understand is why Apple documentation states quite the opposite. Here is the link to the chapter from Apple's iOS 5.0 Library. It states:


Creating a Split View Controller Using a Storyboard

To add a split view controller to your application’s storyboard:

  1. Open your application’s main storyboard.
  2. Drag a split view controller out of the library. This also creates view controllers for the two panes of the split view controller.
  3. For each of the split view controller’s contained view controllers, use the Identity inspector to set the class name of the view controller.

To present the split view interface, do one of the following:

  • Display it as the first scene, by selecting the scene and checking the “Is Initial View Controller” box under the Attributes inspector.
  • Display it from another scene, by adding a modal segue to to it.
  • Display it programmatically, by calling the performSegueWithIdentifier:sender: method to initiate a modal segue.

I was trying it in many ways, but approaches described in last two statements never worked. Both modal segue and performSegue... fail with well-known error:

"*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present a Split View Controllers modally..."

Anyone able to explain that? Is this a bug in XCODE/iOS 5.0 or bug in documentation?

Regards, Petr

Community
  • 1
  • 1
peper-
  • 181
  • 1
  • 5
  • Filed a bug to Apple and also sent feedback for mentioned documentation page. Will post back upon receiving their solution. – peper- Jan 28 '12 at 23:27
  • Have you found a solution? I'm having the same problem and I can't find a way to transition from a View Controller to a SplitView Controller. Thanks in advance. – dcastro Apr 04 '12 at 00:01
  • @dcastro one way to do it could be by using a modal view with size "full Screen". Just a walkaround, not a solution – Simon Apr 23 '12 at 09:22
  • I was getting a **[UISplitViewController setMainNavigationItem:]: unrecognized selector sent to instance** exception under iOS 7 and google did not show any results about that. So if you have the same exception, it's because your SplitView must be the rootViewController. Hope I can help somebody else searching for that error. – Hendrik Apr 04 '14 at 13:21

4 Answers4

2

According to this Apple article, the split view controller must be the root. Here is a snippet:

A split view controller must always be the root of any interface you create. In other words, you must always install the view from a UISplitViewController object as the root view of your application’s window. The panes of your split-view interface may then contain navigation controllers, tab bar controllers, or any other type of view controller you need to implement your interface. Split view controllers cannot be presented modally.

brrmax
  • 21
  • 1
  • Thanks! But your link leads to the same article I'm referring to in my post, just one paragraph above. And that makes it (article in documentation) inconsistent on its own. So let's wait for feedback from fruit company. – peper- Jan 31 '12 at 13:35
1

It seems the documentation was updated soon after this question was posted. According to the new documentation there is no way to segue to a storyboard. Bummer!

BrandonG
  • 876
  • 11
  • 20
0

Yes, It's possible passing from UIView to UISplitView. You have to use a custom segue.

Read this link (translate it from japanese)

UIViewController to UISplitViewController

Dave
  • 1
  • 3
0

As for me, I used MGSplitViewController to implement SplitView with modal or push segues. Try it, it works!

Isuru
  • 30,617
  • 60
  • 187
  • 303
Akhrameev
  • 325
  • 4
  • 12