iOS   发布时间:2022-05-04  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了xcode – iOS6中的纵向和横向模式大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

将我的应用程序更新为iOS6标准时,纵向/横向消失了.当我使用 Xcode 3构建时,Ir工作得很好.但是现在使用最新的Xcode和最新的SDK,旋转消失了,它始终处于纵向模式.无论我在“支持的界面方向”中加入什么.我以前用来获得旋转的代码似乎根本没有效果. 我有这些台词. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOri
将我的应用程序更新为iOS6标准时,纵向/横向消失了.当我使用 Xcode 3构建时,Ir工作得很好.但是现在使用最新的Xcode和最新的SDK,旋转消失了,它始终处于纵向模式.无论我在“支持的界面方向”中加入什么.我以前用来获得旋转的代码似乎根本没有效果.
我有这些台词.

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
    switch (toInterfaceOrientation) {
        case UIInterfaceOrientationPorTrait:
        case UIInterfaceOrientationLandscapeLeft:
        case UIInterfaceOrientationLandscapeRight:
            return YES;
        default:
            return NO;
    }
}

我如何更改以及如何更改以使其再次运行?

解决方法

首先,在AppDelegate中,写下这个.这是非常重要的

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
     return (UIInterfaceOrientationMaskAll);
}

然后,对于只需要PORTraiT模式的UIViewControllers,编写这些函数

- (BOOL)shouldAutorotate
{
     return YES;
}

- (NSUInteger)supportedInterfaceOrientations
{
     return (UIInterfaceOrientationMaskPorTrait);
}

对于也需要LANDSCAPE的UIViewControllers,将掩码更改为All.

- (NSUInteger)supportedInterfaceOrientations
{
    return (UIInterfaceOrientationMaskAllButUpsideDown);
    //OR return (UIInterfaceOrientationMaskAll);
}

现在,如果要在Orientation更改时进行一些更改,请使用此功能.

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{

}

编辑:

很大程度上取决于你的UIViewController嵌入哪个控制器.

例如,如果它在UINavigationController中,那么您可能需将uINavigationController子类化为覆盖这样的方向方法.

子类化UINavigationController(层次结构的顶层视图控制器将控制方向.)确实将其设置为self.window.rootViewController.

- (BOOL)shouldAutorotate
 {
     return self.topViewController.shouldAutorotate;
 }
 - (NSUInteger)supportedInterfaceOrientations
 {
     return self.topViewController.supportedInterfaceOrientations;
 }

从iOS 6开始,UINavigationController不会要求其UIVIewControllers提供方向支持.因此我们需要将其子类化.

大佬总结

以上是大佬教程为你收集整理的xcode – iOS6中的纵向和横向模式全部内容,希望文章能够帮你解决xcode – iOS6中的纵向和横向模式所遇到的程序开发问题。

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

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