Here is my view controller code for the view controller, which I want to display only in portrait orientation ...
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationPortrait];
[[UIDevice currentDevice] setValue:value forKey:@"orientation"];
}
- (BOOL)shouldAutorotate {
return NO;
}
-(NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
and this is how I imagine it ...
MyViewController *myVC = [[MyViewController alloc] init];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:myVC];
[self presentViewController:nav animated:YES completion:nil];
If the device is in landscape orientation and the view controller is displayed, it correctly autorotates portrait orientation. But if you rotate the device after it is displayed, it automatically determines any orientation of the device. I want to prevent autorotation after displaying it and forcibly only portrait orientation for this single controller only. This app is only for iOS8.
Thank you in advance for your wisdom!