Hello, in AppDelegate.h add
@property (nonatomic , assign) bool blockRotation;
and in AppDelegate.m
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if (self.blockRotation) {
return UIInterfaceOrientationMaskPortrait;
}
return UIInterfaceOrientationMaskAll;
}
And in the views you want to disable rotation, just add
- (void)viewDidLoad
{
[super viewDidLoad];
AppDelegate* shared=[UIApplication sharedApplication].delegate;
shared.allowRotation=YES;
}
-(void)viewWillDisappear:(BOOL)animated{
AppDelegate* shared=[UIApplication sharedApplication].delegate;
shared.allowRotation=NO;
}
Another way is to add in each view the
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if(interfaceOrientation == UIInterfaceOrientationPortrait)
return YES;
return NO;
}
Source: link