在我的应用程序中,我一直在使用现已弃用的 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. 已添加
- (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 中视图控制器的不正确旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!