我一直在互联网上寻找解决方案,但一无所获。我正在尝试使我的iOS 5应用程序与iOS 6兼容。我不能让迎新的东西正常工作。我无法检测到何时会发生旋转。下面是我正在尝试的代码:
- (BOOL)shouldAutorotate {
return NO;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
// pre-iOS 6 support
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return (toInterfaceOrientation == UIInterfaceOrientationPortrait);
}
新的supportedInterfaceOrientation:方法可以很好地调用。但是,shouldAutorotate方法不会触发。我需要在旋转时进行一些图像交换,但我无法获得任何旋转即将发生的迹象。
提前谢谢。
发布于 2013-05-08 16:27:34
当使用UINavigationController作为应用程序的基础时,我使用以下子类为我提供了灵活性,允许最顶层的子视图控制器决定旋转。
@interface RotationAwareNavigationController : UINavigationController
@end
@implementation RotationAwareNavigationController
-(NSUInteger)supportedInterfaceOrientations {
UIViewController *top = self.topViewController;
return top.supportedInterfaceOrientations;
}
-(BOOL)shouldAutorotate {
UIViewController *top = self.topViewController;
return [top shouldAutorotate];
}
@end
https://stackoverflow.com/questions/12775265
复制相似问题