首页 > 其他 > 详细

禁止横屏(三个方法放到VC里面 纯代码)

时间:2016-08-10 16:06:54      阅读:268      评论:0      收藏:0      [点我收藏+]
//禁止屏幕旋转(在UIApplication中实现的代码)
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    return UIInterfaceOrientationMaskPortrait;
}
 
 
//phone只支持正方向,

//此方法是ios6.0以前版本控制屏幕旋转的方法(6.0及以后已经被 弃用,,被supportedInterfaceOrientations,,shouldAutorotate两个方法所代替)
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
    return UIInterfaceOrientationIsPortrait(toInterfaceOrientation);
}
//6.0以后控制屏幕旋转的方法
- (BOOL)shouldAutorotate
{
    return NO;
}
-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationPortrait;
}
 

禁止横屏(三个方法放到VC里面 纯代码)

原文:http://www.cnblogs.com/xiao-flag/p/5756923.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!