2 storyboards for portrait and landscape

Is there any possible way to create two storyboards, one portrait and one landscape, and then access them based on the orientation of the device? something like:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight) 
        self.storyboard = (one of the storyboards);
        self.storyboard (the other);


this code doesn't work. is there any code that will work?


source to share

2 answers

I believe there is a much simpler way to deal with different orientations.

You can control the layout of the view directly from the view using the layoutSubviews


This method is called every time the view frame changes (for example, when an orientation change occurs).

Internally, you can make your own layout based on the size of the view.

This assumes that you only want to control the layout if you need different storyboards, because the navigation is different depending on the orientation (which is not recommended by Apple), this will not help you; but then again, this is really not the best way to do it.

Hope it helps!



Changing the storyboard while rotating is quite doable. This is almost the same as changing the view sliders while rotating.

You don't have to shouldAutorotateToInterfaceOrientation:

. This method is called to ask if rotation is allowed. It is not the rotation itself. You must use willRotateToInterfaceOrientation:duration:

because it is triggered when the turn starts.

Regarding changing view controllers in different boards, I would suggest this video tutorial . I watched it a couple days ago and I found myself quite capable of using multiple storyboards after watching.



All Articles