ViewController has the wrong orientation after the landscape has just popped up

In the navigation application, LandscapeViewController only supports landscape mode (all others support both modes). I also have a β€œboot screen” that advises the user to rotate the phone before continuing. Thus, I can make sure that when my landscape is loaded, it will be in landscape mode.

The problem occurs when I rotate the phone in portrait mode while showing LandscapeVC. I press the "Back" button to go one level (to VC, which supports both landscape and portrait modes), but the top level is displayed in landscape mode, even if the phone is in portrait mode. I think this is because when I left this view, I was in portrait mode, then I turned the phone in another mode, so this view did not receive a notification. If I then turn the phone to a different landscape mode (say, LandscapeVC was loaded on the right side, so I would turn the top VC from portrait to left landscape mode), it will be updated.

My question is: how can I notify this top view that the phone has been rotated, so when the user rises after placing the phone in portrait mode, the top view is displayed correctly?

+3
iphone rotation uiviewcontroller
source share
2 answers

When you pull subtasks from the stack and return to the previous view (it currently remains in the landscape, you want to portrait), you can try sending it to the setNeedsLayout selector.

+1
source share

Try it,

This can help you.

All the best

 - (BOOL) shouldAutorotateToInterfaceOrientation:UIInterfaceOrientation)interfaceOrientation { if (interfaceOrientation == UIInterfaceOrientationPortrait) return NO; if (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft ) return YES; return (interfaceOrientation == UIInterfaceOrientationPortrait); } 
0
source share

All Articles