I'm in the process of moving from hard-coded layouts to the new universal storyboard system available in Xcode 6. It's great to be able to create one storyboard that, through the magic of auto-layout, will work on both the iPhone and the iPad. And my understanding is that universal storyboards are backwards-compatible with iOS 7.
However, I'm running into a problem using popover segues. On iOS 8, the new 'Present as Popover' segue will display as a popover on an iPad interface and as a modal view controller on an iPhone interface. This is exactly the behavior I want, but when I run my universal storyboard on iOS 7, the app crashes whenever I attempt a popover segue. Here's the error message I get:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason:
'-[UIPopoverController initWithContentViewController:] called when not
running under UIUserInterfaceIdiomPad.'
This is a bit annoying, as I don't want to have to resort to separate storyboards for each UI idiom.
It looks like these are my choices:
- Create a subclass of
UIStoryboardSegue
that will show a popover on iPad and a modal view on iPhone. This requires manually changing the class of all popover segues in my app. - Create two segues out of every bar button item, table cell, etc. - one that's a pure 'Popover' segue and one that's a pure 'Modal' segue. In this case, I'll be unable to just control-drag to the next screen and will have to create custom action methods that will invoke the right segue based on the current UI idiom.
- Abandon universal storyboards and create device-specific storyboards until I can require iOS 8 from my users.
None of these are great alternatives, so I was wondering: do I have any other options? Am I missing any problems with my proposed solutions?