We had the exactly same problem.
You can rotate it programmatically by the code -
if ([UIApplication sharedApplication].statusBarOrientation != UIInterfaceOrientationPortrait) {
NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationPortrait];
[[UIDevice currentDevice] setValue:value forKey:@"orientation"];
}
There are 2 possible options -
1) before you dismiss the presented viewController, rotate to portrait if
needed
2) after you dismiss, rotate to portrait in the "viewDidAppear" of the presenting viewController.
One issue with this, is that you can't pass a completion block, but you can use the next callback in iOS8:
-(void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
{
if (self.needToDismissAfterRotatation)
self.needToDismissAfterRotatation = NO;
[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) {
} completion:^(id<UIViewControllerTransitionCoordinatorContext> context) {
// dismiss
}];
}
}
By the way, in iOS8 apple did a huge change in the way the screen rotates, when the app rotates, the screen rotates, and all the elements in the UIWindow rotates as well, this is why when the presented viewController rotates to landscape, also the presenting viewController rotates, even if it only supports portrait...
We struggled with this issue for many days, finally we came up with a solution to put the presented viewController in a new UIWindow, and this way it keeps the presenting viewController in portrait all the time
example project for that:
"modalViewController" in UIWindow