简体   繁体   中英

The Device Orientation method is not working for ios6

My supports both Landscape & Portrait mode in ios6. I also try with new methods of device rotation, But the methods are not called & it does not support the orientation.

My code is as follow:

-(NSUInteger)supportedInterfaceOrientations
{
    NSLog(@"supportedInterfaceOrientations...");
    return UIInterfaceOrientationMaskAll;
}

-(BOOL)shouldAutorotate
{
    NSLog(@"shouldAutoRotate...");
    return YES;
}

I don't know the issue for this.

Thanks...

Do you support all Interface Orientations in the Target respectively in the Info.plist

支持的界面方向 You would need to check all these images to support all Orientations

Try this,

Because You Mentioned : Deployment target is ios5 but you run the app in ios6.

In .pch File,

#define IOS_OLDER_THAN_6 ( [ [ [ UIDevice currentDevice ] systemVersion ] floatValue ] < 6.0 )

#define IOS_NEWER_OR_EQUAL_TO_6 ( [ [ [ UIDevice currentDevice ] systemVersion ] floatValue ] >= 6.0 )

And In Controller File, Check with Conditions,

#ifdef IOS_OLDER_THAN_6
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
     return toInterfaceOrientation;
}
#endif

#ifdef IOS_NEWER_OR_EQUAL_TO_6
-(BOOL)shouldAutorotate {
     return YES;
}

- (NSUInteger)supportedInterfaceOrientations {
     return (UIInterfaceOrientationMaskAll);
}
#endif

Hopefully, It will be helpful to you. Thanks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM