Based on the discussing on Apple's forum, this method works great on iOS < 11 device (But > iOS 6)
This will prevent any rotation.
- (BOOL)shouldAutorotate
{
return NO;
}
This will only rotate to portrait (right-side-up or up-side-down).
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait + UIInterfaceOrientationMaskPortraitUpsideDown;
}
However, it's not working on iOS 11 Beta 9;
If you have an app that allow all orientations but want to set MainViewController to Portrait only by using this.
If you hold your device landscape and start the app, after a launching screen, the statusBar will be on the top of screen (when landscape) and your view still portrait.
If you use method to switch rootViewController like this answer, you will end up a landscape rendered view that force showing in portrait.
Some example graph like this one:
The Gear Icon is at correct location but that was from a library. Everything else looks like landscape.
Thanks