iOS 6中视图控制器的旋转不正确 [英] Incorrect rotation of a view controller in iOS 6
问题描述
在我的应用程序中,我一直在使用现已弃用的shouldAutoRotateToFace方法。现在,当使用iOS 6模拟器时,我的所有子视图都会在设备处于横向状态时旋转为纵向。有谁知道是什么原因引起的?我已经尝试使用supportedOrientations方法替换我的主视图控制器中的autorotate(或者你现在应该使用的任何东西)。
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).
推荐答案
如果您可以登录Apple dev论坛,请查看此帖子。
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
,我不得不添加
didn't just return YES
, I had to add
- (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,我没有使用所有方向掩码,因为我需要使用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中视图控制器的旋转不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!