0

I am working on an app which supports iPhone and iPad. For iPad we are supporting both portrait and landscape (iOS 9.0). But for some reason, to satisfy the requirement we have to maintain separate storyboards for landscape UI. Is this accepeted by Apple.

Want to make sure that this is as per APPLE guidelines.

jscs
  • 63,694
  • 13
  • 151
  • 195
Vinayak Hejib
  • 721
  • 7
  • 17
  • Check the answer http://stackoverflow.com/a/8863381/5109911 – Marco Santarossa Aug 09 '16 at 15:34
  • @SaintThread: Thank you very much man.. But my concern is that I have some viewcontroller which I need only in iPad and in that some are for Portrait and some are for Landscape... – Vinayak Hejib Aug 09 '16 at 16:19
  • This question is off-topic because it is about App Store compliance, not a coding issue. Please see [Are developer-centric questions about application stores on topic for Stack Overflow?](http://meta.stackoverflow.com/q/175701) – jscs Aug 09 '16 at 17:05

2 Answers2

1

If you want different storyboard you can try the following code in the main view controller:

Obj-C

- (void) viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
    NSString* storyboard = (size.width > size.height ) ? @"lanscape" : @"portrait";
    UIStoryboard* mainView = [UIStoryboard storyboardWithName:storyboard bundle:nil];
    UIViewController* viewcontroller = [mainView instantiateInitialViewController]
    // remove privious view controller
    // add newViewcontroller
}

Swift

override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
    let storyboardName = (size.width > size.height ) ? "lanscape" : "portrait"

    var mainView: UIStoryboard!
    mainView = UIStoryboard(name: storyboardName, bundle: nil)
    if let newViewcontroller : UIViewController = mainView.instantiateInitialViewController() {
        // remove privious view controller
        // add newViewcontroller
    }
}

I hope it could help you.

Marco Santarossa
  • 4,058
  • 1
  • 29
  • 49
0

You can use two separate story boards for iPhone and iPad only if there's 2 orientations(Landscape and portrait) needed for iPad and the UI for each orientation changes drastically. Since iPad's size class is Regular-Regular for both orientations you can still go ahead and build UI in one storyboard.

There can be situations where you cannot keep manipulating constraints or views for different orientations under same size class. It would become cumbersome and too complicated further.

Hence its always a better idea to keep 2 storyboard (1 for another orientation of iPad) them separate if the UI for both orientation for iPad is different.

However for iPhone and for one of the orientaion of iPad you can still go ahead with 1 storyboard as they inherit different size classes.

Vinayak Hejib
  • 721
  • 7
  • 17