iOS   发布时间:2022-05-04  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了iOS 6:将视图控制器推入导航控制器堆栈时如何强制更改方向大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

参见英文答案 > In iOS6, trouble forcing ViewController to certain interfaceOrientation when pushed on stack                                    3个 我认为这个问题到现在应该被问过一百万次,但我仍然无法找到答案. 这是我的层次结构:UINavigationControl
参见英文答案 > In iOS6,trouble forcing ViewController to certain interfaceOrientation when pushed on stack                                    3个
我认为这个问题到现在应该被问过一百万次,但我仍然无法找到答案.

这是我的层次结构:UINavigationController – > UIViewController 1 – >(推) – > UIViewController 2

UINavigationController:支持所有可能的方向
UIViewController 1:仅支持肖像
UIViewController 2:仅支持横向

如何仅将uIViewController 1锁定为纵向,同时仅将uIViewController 2锁定为横向?它甚至可能吗?到目前为止,我看到的是UIViewController 2始终采用UIViewController 1的方向.

请注意,这仅适用于iOS 6.

谢谢!

解决方法

我也发现了同样的问题.我发现每次都应该调用不应该调用函数,所以我改变了方向程序

先导入这个

#import <objc/message.h>

然后

-(void)viewDidAppear:(BOOL)animated
{

     if(UIDeviceOrientationIsPorTrait(self.interfaceOrientation)){
        if ([[UIDevice currentDevice] respondsToSELEctor:@SELEctor(setOrientation:)])
        {
            objc_msgSend([UIDevice currentDevice],@SELEctor(setOrientation:),UIInterfaceOrientationLandscapeLeft );


        }
    }

}

希望这能帮助你.

@H_450_58@

大佬总结

以上是大佬教程为你收集整理的iOS 6:将视图控制器推入导航控制器堆栈时如何强制更改方向全部内容,希望文章能够帮你解决iOS 6:将视图控制器推入导航控制器堆栈时如何强制更改方向所遇到的程序开发问题。

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

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