首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >iOS 6 shouldAutorotate:未被调用

iOS 6 shouldAutorotate:未被调用
EN

Stack Overflow用户
提问于 2012-10-08 12:20:01
回答 4查看 48.7K关注 0票数 48

我一直在互联网上寻找解决方案,但一无所获。我正在尝试使我的iOS 5应用程序与iOS 6兼容。我不能让迎新的东西正常工作。我无法检测到何时会发生旋转。下面是我正在尝试的代码:

代码语言:javascript
运行
复制
- (BOOL)shouldAutorotate {
    return NO;
}

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskPortrait;
}
// pre-iOS 6 support
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
    return (toInterfaceOrientation == UIInterfaceOrientationPortrait);
}

新的supportedInterfaceOrientation:方法可以很好地调用。但是,shouldAutorotate方法不会触发。我需要在旋转时进行一些图像交换,但我无法获得任何旋转即将发生的迹象。

提前谢谢。

EN

Stack Overflow用户

发布于 2013-05-08 16:27:34

当使用UINavigationController作为应用程序的基础时,我使用以下子类为我提供了灵活性,允许最顶层的子视图控制器决定旋转。

代码语言:javascript
运行
复制
@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
票数 45
EN
查看全部 4 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12775265

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档