Reputation: 801
i have an application build on xcode 4.2 , which supports only portrait orientation, it works fine with all devices except ios6 .. In Ios 6 devices it is showing both orientations .. I need only portrait orientation .. i am using navigation controller .. IN appdelegate::
- (BOOL)shouldAutorotate
{
return ([[UIDevice currentDevice] orientation]==UIInterfaceOrientationPortrait);
}
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
return (UIInterfaceOrientationMaskPortrait);
}
in other viewControllers ::
- (BOOL)shouldAutorotate {
return YES;
}
- (void)viewDidLayoutSubviews
{
DisplayFunctionName;
NSLog(@"orientation: %d",self.interfaceOrientation);
}
- (NSUInteger)supportedInterfaceOrientations
{
if (UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad)
{
return (UIInterfaceOrientationMaskAll);
}
else
{
return (UIInterfaceOrientationMaskPortrait);
}
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
DisplayFunctionName;
NSLog(@"orientation: %d",interfaceOrientation);
return (interfaceOrientation==UIInterfaceOrientationPortrait);
}
Upvotes: 1
Views: 122
Reputation: 2437
In IOS6 handling of Orientation is difficult is case when you want portrait orientation for some views and for some you want landscape orientation, but its very easy if you want only one orientation support for entire app. simple go to Supporting Files and then open the info.plist in your app and remove all other orientation except one that you want.. below are few screen shot which help you to fix your issue
after removing all other orientation your info.plist will be looks like below
i hope it works for you.Thanks
Upvotes: 2
Reputation: 5955
Try using these ,
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationPortrait;
}
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
return UIInterfaceOrientationPortrait;
}
Upvotes: 0
Reputation: 19134
iOS 6
shouldAutorotateToInterfaceOrientation: is deprecated and replaced by
shouldAutorotate
Check this : https://stackoverflow.com/a/14938444/305135
Upvotes: 1