ViewController has wrong orientation after Landscape-only has been popped
In a navigation-based app, LandscapeViewController only supports landscape mode (all others support both modes). I also have a "loading screen" that advises the user to rotate the phone before continuing. This way I can make sure that when my landscape view loads, that it's in landscape mode.
The problem comes when I rotate the phone to portrait mode while still showing LandscapeVC. I press the Back navigation button to navigate up one level (to a VC that supports both landscape and portrait modes), but the upper level shows in landscape mode even though the phone is in portrait mode. I guess this is because when I left this view I was in portrait mode, I then rotated the phone while in another view, so this view has not received the notification. If I then proceed to rotate the 开发者_运维技巧phone to the other landscape mode (say the LandscapeVC was loaded on its right side, so I'd rotate the upper VC from portrait to the left landscape mode), it will update.
My question is: how can I notify this upper view that the phone was rotated, so when the user goes up after putting the phone in portrait mode, the upper view shows correctly?
Where you pop the sub-view off the stack and return to the previous view (currently stays in landscape, you'd like in portrait), you could try sending it to the setNeedsLayout
selector.
Please try this,
This may help you.
All the best
- (BOOL) shouldAutorotateToInterfaceOrientation:UIInterfaceOrientation)interfaceOrientation {
if (interfaceOrientation == UIInterfaceOrientationPortrait)
return NO;
if (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft )
return YES;
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
精彩评论