iOS 6 中视图控制器的不正确旋转

Incorrect rotation of a view controller in iOS 6(iOS 6 中视图控制器的不正确旋转)
本文介绍了iOS 6 中视图控制器的不正确旋转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我一直在使用现已弃用的 shouldAutoRotateToFace 方法.现在,当使用 iOS 6 模拟器时,我的所有子视图都旋转到纵向,而设备处于横向.有谁知道可能导致这种情况的原因?我已经尝试用supportedOrientations方法(或者你现在应该使用的任何方法)替换我的主视图控制器中的自动旋转.

In my app I've been using the now deprecated shouldAutoRotateToFace method. Now when using the iOS 6 simulator, all of my subviews are rotated to portrait orientation while the device is in landscape. Does anyone have any idea what could cause this? I've already tried replacing should autorotate in my main view controller with the supportedOrientations method (or whatever it is that you're now supposed to use instead).

推荐答案

如果可以登录苹果开发论坛,看看这个帖子.

If you can log in to the Apple dev forums, check out this thread.

基本上,这是对我有帮助的信息:

Basically, this is the information that helped me:

1. 我必须在

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

2.对于视图控制器

- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation

没有只返回YES,我必须添加

- (NSUInteger)supportedInterfaceOrientations

返回相同的值

3. 已添加<​​/p>

- (BOOL)shouldAutorotate {
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations {
    return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft |
            UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortraitUpsideDown);
}

到 mainViewController.m

to mainViewController.m

4.已添加

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
    return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft |
            UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortraitUpsideDown);
}

到 appDelegate.m(我相信这是可选的,用于设置默认值,以防它们未在应用程序的 Info.plist 文件或单个视图控制器中指定)

to appDelegate.m (I believe this is optional, for setting default values in case they're not specified in the app's Info.plist file, or in individual view controllers)



因为我希望我的代码向后兼容回 3.0,所以我没有使用 All 方向掩码,因为我需要使用 XCode 4.3



Since I want my code backwards compatible back to 3.0 I didn't use the All orientation masks, as I need to compile using XCode 4.3

这篇关于iOS 6 中视图控制器的不正确旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Why local notification is not firing for UNCalendarNotificationTrigger(为什么没有为UNCalendarNotificationTrigger触发本地通知)
iOS VoiceOver functionality changes with Bundle Identifier(IOS画外音功能随捆绑包标识符而变化)
tabbar middle tab out of tabbar corner(选项卡栏中间的选项卡角外)
Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Get an event when UIBarButtonItem menu is displayed(显示UIBarButtonItem菜单时获取事件)