Reputation: 939
I need to open the first view controller only in portrait mode. As the rest view controllers will use both orientation. So i have added both orientation in plist file.
-(BOOL) shouldAutorotate {
//Never called
}
- (NSUInteger) supportedInterfaceOrientations {
//Never called
}
can any one tell me how to restrict
Upvotes: 8
Views: 9236
Reputation: 939
Fixed it simply by creating UINavigationController class and overriding
-(NSUInteger)supportedInterfaceOrientations
{
AppDelegate *appDelegate = (AppDelegate *) [UIApplication sharedApplication].delegate;
if(appDelegate.isOrientationOn) {
return UIInterfaceOrientationMaskAll;
}
return UIInterfaceOrientationMaskPortrait;
}
Use this custom navigation controller class in root window and that's all.
Upvotes: 11
Reputation: 119
This will lock your View Controller's Orientation in Portrait Mode:
- (BOOL)shouldAutorotate
{
return NO;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
Upvotes: 2