I'm new to the IOS development and I have to give landscape and Portrait only for one screen and all others should be portrait only. I use following code in AppDelegate file and change it in my screen. But when I press back button previous screen not rotate to Portrait again?
- (UIInterfaceOrientationMask)application:(UIApplication *) application
supportedInterfaceOrientationsForWindow:(UIWindow *) window {
if (self.allowLandscape) {
return UIInterfaceOrientationMaskLandscapeLeft &
UIInterfaceOrientationMaskLandscapeRight;
}
return UIInterfaceOrientationMaskPortrait;
}
Add below code inside viewWillAppear on all viewControllers you want to show portrait only. don't forget to mark Device Orientation to both Portrait and Landscape modes.
NSNumber *value = [NSNumber numberWithInt:UIDeviceOrientationPortrait];
[[UIDevice currentDevice] setValue:value forKey:@"orientation"];