加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

iphone – iOS 6 – (BOOL)shouldAutorotate没有被调用导航控制

发布时间:2020-12-14 19:56:51 所属栏目:百科 来源:网络整理
导读:对于我的应用程序,rootViewController是navgationController. 我找到 推动控制器 – (BOOL)shouldAutorotate没有被调用. 和 – (NSUInteger)supportedInterfaceOrientations只被调用一次. 我在xcode的项目摘要(或plist)中正确检查了windows所有方向支持. 我
对于我的应用程序,rootViewController是navgationController.

我找到
推动控制器

– (BOOL)shouldAutorotate没有被调用.

– (NSUInteger)supportedInterfaceOrientations只被调用一次.

我在xcode的项目摘要(或plist)中正确检查了windows所有方向支持.

我想要调用这些方法,因为有一些uicontrol定位代码,我想以编程方式执行方向更改.

我通过覆盖(类别)导航控制器的以下方法解决了这个问题

-(BOOL)shouldAutorotate;

-(NSUInteger)supportedInterfaceOrientations;

我检查了哪个控制器被推入,因此在导航控制器的以下方法中调用了相应的推控制器的uicontrol定位代码

(NSUInteger)supportedInterfaceOrientations;

这工作正常,但我不认为这是正确的方法.请帮我解决更好的解决方案.

解决方法

您可以查看以下链接,您需要创建自定义导航以支持自动旋转

http://mobileappdevpage.blogspot.in/2012/11/how-to-use-should-autorotateios-6-with.html

另一种方法是通过创建UINaviagationController类来实现

.h文件的代码是

@interface UINavigationController (autorotation)

-(BOOL)shouldAutorotate;
-(NSUInteger)supportedInterfaceOrientations;

和.m文件的代码是

@implementation UINavigationController (autorotation)

-(BOOL)shouldAutorotate
{

    UIInterfaceOrientation interfaceOrientation = [UIApplication sharedApplication].statusBarOrientation;
    [self.topViewController shouldAutorotate];
    return YES;

}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskAll;

}
@end

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读