iOS   发布时间:2022-05-04  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了iphone – iOS 6中视图控制器的旋转错误大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

在我的应用程序中,我一直在使用现已弃用的shouldAutoRotateToFace方法.现在,当使用iOS 6模拟器时,我的所有子视图都会在设备处于横向状态时旋转为纵向.有谁知道是什么原因引起的?我已经尝试使用supportedOrientations方法替换我的主视图控制器中的autorotate(或者你现在应该使用的任何东西). 如果您可以登录Apple dev论坛, check out t
在我的应用程序中,我一直在使用现已弃用的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进行编译

@H_262_67@

大佬总结

以上是大佬教程为你收集整理的iphone – iOS 6中视图控制器的旋转错误全部内容,希望文章能够帮你解决iphone – iOS 6中视图控制器的旋转错误所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。