Do I need to use 2 storyboards for a universal application?

I have a project for iPhone and iPad. The iPad needs a separate view controller. Are we creating two separate storyboards? One for the iPhone (using autorun we can support all devices) and two for the iPad. My doubt is that it is only in its original form. Internal representations are repeated. What will be your approach to the storyboard?

+6
source share
6 answers

No need for two storyboards anymore in iOS 8! We can use the Adaptive UI to adapt the same storyboard of all the different sizes of the iPad and iPhone.

Here you can find a good tutorial http://www.raywenderlich.com/83276/beginning-adaptive-layout-tutorial

And also you can find a beautiful apple video at WWDC here and find "Creating responsive applications using UIKit"

Basically, we can handle different screen sizes by defining elements of our interface in a storyboard for different size classes. We can also define various auto-layout restrictions for different size classes.

And these are all the possible size classes in iOS 8 (I took the image from https://medium.com/@getaaron/ios-8-development-tips-for-iphone-6-and-iwatch-1c772554ffe0 )

enter image description here

+14
source

For iOS 7 and earlier, yes, use two storyboards and two completely different interfaces, since the iPhone does not have a split view controller.

For iOS 8, use one storyboard and use the UISplitViewController on both the iPad and iPhone. Create a new project from the universal version of the Master-Detail Xcode 6 application template to learn all about how it works! It is automatically a split view controller on the iPad and a navigation interface on the iPhone.

+6
source

Even with an adaptive interface, personally, I prefer to work on different storyboards. For a complex layout, this is simpler and it will not easily break the layout for a different screen size. Too many restrictions can complicate the job. Also, moving the hierarchy of objects will break the layout for another screen.

As a bonus, if you work with a small mac, like mackbook air or an old mac, it also reduces load times and improves responsiveness when working with a storyboard.

+2
source

On iOS 8, you don’t need two storyboards, since one storyboard can handle both iPhone and iPad; In addition, UISplitViewController is supported on the phone in this OS.

For earlier iOS releases, you will need two storyboards.

+1
source

You can have a lot more than just two storyboards. If you cannot select a size class / auto layout for the task of the view controller shared between iPhone and iPad, you can break this part down into separate storyboards. You can then create a third storyboard that stores shared view controllers. You can then instantiate this storyboard in code and use it to instantiate your view controllers.

+1
source

I managed to get this script (a split controller in a universal storyboard that works on both iOS8 and iOS7), causing another session on iOS7 and iPhone. My scenario is as follows:

I have an input controller that should go to the main controller (by default).

When on iOS8 or iPad I use segue points for a split view controller, while on iOS7-iPhone I use another segue that points directly to the left navigation controller of the split controller (completely bypassing it).

If you have a detailed segment from the left controller that points to the right navigation controller (and you should), and if the segue type is “Show Detail” (and it should), then it will work like a normal click in iOS7-iPhone (namely this is what we want).

At the same time, I noticed that the segue destination controller in the IOS7-iPhone script becomes the root view controller of the correct navigation (although segue indicates navigation), so if you have code in prepareForSegue you may need to adapt it to handle them differently )

(To determine if the platform is iOS8, and if I'm on the iPhone / iPad idiom, I use the standard

 [[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0 and UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) 
+1
source

Source: https://habr.com/ru/post/976738/


All Articles