Universal app in xcode 8 one or two storyboards

Hi


All the tutorials out there tells me I should get two seperate storyboards when I create a universal app, one iphone and one ipad


But when I create my univeraal project I only get a single main storyboard


Am I doing something wrong ?if so what?


M

Accepted Reply

Having two storyboards might make sense, depending on your app, but a lot of apps these days are adaptive. That is, they don’t have custom UIs for each type of device, but have one UI that adapts based on the size class. A good introduction to this concept is WWDC 2016 Session 222 Making Apps Adaptive.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Replies

Having two storyboards might make sense, depending on your app, but a lot of apps these days are adaptive. That is, they don’t have custom UIs for each type of device, but have one UI that adapts based on the size class. A good introduction to this concept is WWDC 2016 Session 222 Making Apps Adaptive.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

That video was really helpful, thanks a lot.

I watched the videos but there is no way to make an entire scene adaptive. That's the scenario I have: I need a split view controller for iPad as my initial view controller, but a tab bar view controller for iPhone. As far as I could understand, size classes are for views, not for scenes. So, I cannot have a scene that exists only in one size class, which would solve my problem.


So, in a scenario like this, how to proceed?

Just in case someone's still looking for this, here is my solution. Replace the method in the AppDelegate class by the following:


    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        /
        var storyboard: UIStoryboard!
        let device = UIDevice.current.userInterfaceIdiom
        if device == .pad {
            storyboard = UIStoryboard(name: "iPad", bundle: nil)
        } else {
            storyboard = UIStoryboard(name: "Main", bundle: nil)
        }
        window?.rootViewController = storyboard.instantiateInitialViewController()
        window?.makeKeyAndVisible()
       
        return true
    }


This code loads the iPad.storyboard file on iPads or the Main.storyboard file in any other device.

Back when the iPad was just coming out, Apple was pushing to make the app on an iPad a unique experience from the iPhone due to the greater real estate on the iPad. But now, they want things to be more the same. When I first adapted to the iPad, just before the iPad went on sale, I had completely different code and completely different .xib files. I have a tabbar comtroller on the iPhone and a splitview controller on the iPad. My app is old now and needs to be modernized. I'd love to make it adaptive but the differences are too great, I think.