首页 > 其他 > 详细

iPhone屏幕旋转

时间:2014-02-15 03:46:53      阅读:324      评论:0      收藏:0      [点我收藏+]

iPhone屏幕内容旋转

在iOS6之前的版本中,通常使用 shouldAutorotateToInterfaceOrientation 来单独控制某个UIViewController的方向,需要哪个viewController支持旋转,只需要重写shouldAutorotateToInterfaceOrientation方法。

但是iOS 6里屏幕旋转改变了很多,之前的 shouldAutorotateToInterfaceOrientation 被列为 DEPRECATED 方法,从IOS6开始使用新的方法来控制屏幕内容的旋转

 

操作方法

1:定义一个UINavigationController的子类,然后添加下面的代码

- (BOOL)shouldAutorotate

{

    return self.topViewController.shouldAutorotate;

}

 

- (NSUInteger)supportedInterfaceOrientations

{

    returnself.topViewController.supportedInterfaceOrientations;

}

 

2:将window.RootController 制定为这个自定义的类

 

3:重载下面两个方法来控制页面内容是否随着屏幕旋转

-(BOOL)shouldAutorotate

{

    return NO;

}

 

-(NSUInteger)supportedInterfaceOrientations

{

    return UIInterfaceOrientationMaskPortrait;

}

 

 

Jason

2014年02月14日

iPhone屏幕旋转

原文:http://www.cnblogs.com/xingchen/p/3549590.html

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