美文网首页
屏幕旋转时不调用shouldAutorotate

屏幕旋转时不调用shouldAutorotate

作者: kangyiii | 来源:发表于2018-05-25 17:47 被阅读0次

    原因:

    可能是被当前Controller的父视图拦截导致

    解决方法:

    1.如果当前Controller被NavigationController管理,直接重写shouldAutorotate方法

    -(BOOL)shouldAutorotate{
        return NO;
    }
    

    2.如果当前Controller被NavigationController管理,那么在1的基础上在NavigationController中重写shouldAutorotate方法

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

    3.如果当前Controller被NavigationController管理的同时,NavigationController又作为TabbarController的子Controller的话,在2基础上在TabbarController内重写shouldAutorotate方法

     - (BOOL)shouldAutorotate{
        return self.selectedViewController.shouldAutorotate;
    }
    

    注意:第2种和第3种方式适用于自定义NavigationController和自定义TabbarController

    相关文章

      网友评论

          本文标题:屏幕旋转时不调用shouldAutorotate

          本文链接:https://www.haomeiwen.com/subject/dkuujftx.html