只在某页面屏幕旋转,其他竖屏

来源:互联网 发布:数据港 编辑:程序博客网 时间:2024/06/11 00:43

从根视图一层一层返回,直到最上层,从最上层设置是否支持. 

当初  电影时光  一直想加进去,在视频播放时横屏,其他竖屏. 现在是会了.  真机测试的时候一定要把设置里的屏幕锁定去掉.

UITabBarController中设置
- (BOOL)shouldAutorotate
{
    return [self.selectedViewController shouldAutorotate];
}

- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
    return [self.selectedViewController supportedInterfaceOrientations];
}


UINavigationController中设置


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

- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
    return [self.topViewController supportedInterfaceOrientations];
}




某个页面如果不支持
- (BOOL)shouldAutorotate
{
    return NO;
}

某个页面如果支持
- (BOOL)shouldAutorotate
{
    return YES;
}

- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskAll;

}

/**

    刚进入时的方向

 */

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {

    return UIInterfaceOrientationMaskAll;      // 全屏幕

    return UIInterfaceOrientationMaskPortrait ;//正向

}

/**

 屏幕旋转的调用函数

 */

- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {

    

}

//获取当前 状态栏的方向

[[UIApplicationsharedApplication] statusBarOrientation]



0 0
原创粉丝点击