Xcode 9 Layout: Is there a way to build a new storyboard with the same content from the iPhone just for the iPads?

I have issues getting the Layout with Constraints for all devices, so my question would be if the is a way to build a extra storyboard with the same code, segues etc. just for iPads, so it would be easier to get the layout correctly.

1 answer

  • answered 2018-08-14 14:54 Dhaval D.

    Yes there is way, you can make duplicate copy of existing storyboard and rename it like iPad_Main.storyboard and after that you have to correct some constraint or change values which look good for iPad screens.

    And after that before init any view controller you have to check device is iPad or iPhone and based on that you have to use your storyboard.

    let deviceIdiom = UIScreen.main.traitCollection.userInterfaceIdiom
    let storyboard : UIStoryBoard!
    if (deviceIdiom == .pad) {
       storyboard = UIStoryboard(name: "iPad_Main", bundle: nil)
    else {
       storyboard = UIStoryboard(name: "Main", bundle: nil)
    // Use storyboard to get desired controller using StoryboardID of UIViewController