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:
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.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?
Xcode 6 supports unified storyboards. A storyboard can add or remove views and layout constraints based on the size class that the view controller is displayed in. Rather than maintaining two separate (but similar) storyboards, you can make a single storyboard for multiple size classes.
But Size classes are based on UITraitCollection which is supported on iOS8. That's why it's crashing on iOS7.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With