首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >模拟器中的iOS 6自动旋转与实际iOS 6设备不同

模拟器中的iOS 6自动旋转与实际iOS 6设备不同
EN

Stack Overflow用户
提问于 2012-09-13 20:53:59
回答 4查看 7.7K关注 0票数 8

我的应用程序不能在iOS 6 GM模拟器中自动旋转,但它可以在设备上使用相同版本的iOS。这会不会是模拟器的bug?这个应用使用的是过时的自动旋转方法,但它们在设备本身上工作得很好,这让我想知道模拟器app是否有所不同?

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2012-09-13 22:04:01

这是我为了让我的应用程序再次工作而添加的:

代码语言:javascript
运行
复制
// Tell the system what we support
- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskAllButUpsideDown;
}

// Tell the system It should autorotate
- (BOOL) shouldAutorotate {
    return YES;
}

// Tell the system which initial orientation we want to have
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationPortrait;
}
票数 11
EN

Stack Overflow用户

发布于 2012-09-27 21:34:28

它应该仍然适用于弃用的rotate方法,但您需要将以下内容添加到didFinishLaunchingWithOptions:方法中:

代码语言:javascript
运行
复制
self.window.rootViewController = yourRootViewController;

这将告诉主window将旋转通知发送到哪个视图控制器。这是iOS 6.0SDK中的新特性。

票数 15
EN

Stack Overflow用户

发布于 2012-09-27 02:06:03

添加以下内容不足以使其在模拟器上工作:

代码语言:javascript
运行
复制
- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskAllButUpsideDown;
}
- (BOOL) shouldAutorotate {
    return YES;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationPortrait;
}

为了使其正常工作,我还在appDelegate类的didFinishLaunchingWithOptions函数中添加了以下内容:

代码语言:javascript
运行
复制
self.window.rootViewController = viewController;

在此添加之后,我停止了收到以下错误:在应用程序启动结束时,应用程序窗口应该有一个根视图控制器

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12406748

复制
相关文章

相似问题

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