iOS中的屏幕旋转

2种方法

应用级别控制

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window

{

    returnUIInterfaceOrientationMaskAll;

}


视图控制器控制

//iOS 6-

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation

{

    if (toInterfaceOrientation ==UIInterfaceOrientationLandscapeLeft | toInterfaceOrientation ==UIInterfaceOrientationLandscapeRight)

    {

        return YES;

    }

    else

    {

        return NO;

    }

}


//iOS 6+

- (BOOL)shouldAutorotate

{

    return YES;

}

- (NSUInteger)supportedInterfaceOrientations

{

//    return UIInterfaceOrientationMaskLandscape;

    returnUIInterfaceOrientationMaskAll;

}

注意:

如果控制器的父控制器为导航控制器或TabBar控制器,要在导航控制器或者TabBar控制器修改在导航控制器或者Tab控制器的子控制器修改是没效的。



郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。