iphone – iOS 6中视图控制器的旋转错误
发布时间:2020-12-15 01:47:59 所属栏目:百科 来源:网络整理
导读:在我的应用程序中,我一直在使用现已弃用的shouldAutoRotateToFace方法.现在,当使用iOS 6模拟器时,我的所有子视图都会在设备处于横向状态时旋转为纵向.有谁知道是什么原因引起的?我已经尝试使用supportedOrientations方法替换我的主视图控制器中的autorotate
在我的应用程序中,我一直在使用现已弃用的shouldAutoRotateToFace方法.现在,当使用iOS 6模拟器时,我的所有子视图都会在设备处于横向状态时旋转为纵向.有谁知道是什么原因引起的?我已经尝试使用supportedOrientations方法替换我的主视图控制器中的autorotate(或者你现在应该使用的任何东西).
解决方法
如果您可以登录Apple dev论坛,check out this thread.
基本上,这是帮助我的信息: 我必须在中设置window.rootViewController = mainViewController - (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 4.补充说 - (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortraitUpsideDown); } 到appDelegate.m(我相信这是可选的,用于设置默认值,以防它们未在应用程序的Info.plist文件中或在单个视图控制器中指定) 由于我希望我的代码向后兼容回3.0,我没有使用All orientation mask,因为我需要使用XCode 4.3进行编译 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |