[英]orientation issue in IOS 5.1?
我已经在IOS 6.0中实现了示例代码,并具有方向支持功能,但可以正常运行,但如果我不支持以ipad 1(IOS 5.1)方向运行相同的应用程序,我知道IOS 6.0在iOS 5.1中已弃用某些方法如何解决此问题?
You need to implement the old rotation methods in you view controllers to support iOS 5 or lower rotation. 您需要在视图控制器中实现旧的旋转方法,以支持iOS 5或更低版本的旋转。
Yes the methods have been deprecated but are still need by the older versions of iOS. 是的,这些方法已被弃用,但旧版本的iOS仍需要使用。
For iOS 6+ use these methods 对于iOS 6+,请使用以下方法
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
- (BOOL)shouldAutorotate {
return UIInterfaceOrientationMaskPortrait;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationPortrait;
}
and for iOS 5.0 and all previous use this 并且适用于iOS 5.0和所有以前的版本
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
Use the following code in .m file. 在.m文件中使用以下代码。
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if(interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
return NO;
}
else {
return YES;
}
}
This works in iOS 5.1,6.1.3 and 7.0.2. 这适用于iOS 5.1、6.1.3和7.0.2。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.