我们的应用仅支持横向模式,并且需要支持iOS5.1&6.0&7.0。到目前为止,我们已经设置了rootviewcontroller和BaseSdk:7.0 DeploymentTarget:5.1
我们的应用程序在iOS 5和ios 6上运行良好。但是在iOS7中,当存在alertview并且用户旋转为纵向时,alertview也旋转为potrait,这在iOS5和6中不会发生。它不会旋转到风景。
注意:我的ViewController的方向很好。它始终仅支持横向。
我通过实现supportedInterfaceOrientations方法解决了该问题:仅在使用之前
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if (landscapeOnly) {
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
else {
return YES;
}
}
现在,我还实现了supportedInterfaceOrientations方法。因为当出现警报视图时,将自动调用supportedInterfaceOrientations。
-(NSUInteger)supportedInterfaceOrientations{
if (landscapeOnly) {
return ((1 << UIInterfaceOrientationLandscapeLeft) | (1 << UIInterfaceOrientationLandscapeRight));
}
else{
return ((1 << UIInterfaceOrientationLandscapeLeft) | (1 << UIInterfaceOrientationLandscapeRight) | (1 << UIInterfaceOrientationPortrait) | (1 << UIInterfaceOrientationPortraitUpsideDown));
}
}
(1 << UIInterfaceOrientationLandscapeLeft)用于UIInterfaceOrientationMaskLandscape
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句