首页 > 其他 > 详细

ios 单个ViewController屏幕旋转

时间:2014-03-05 02:09:55      阅读:454      评论:0      收藏:0      [点我收藏+]

如果需要旋转的ViewController 使用了UINavigationController,对UINavigationController进行如下扩展

bubuko.com,布布扣
@implementation UINavigationController(shouldAutorotate)
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationPortrait); }
- (BOOL)shouldAutorotate { return self.topViewController.shouldAutorotate; }
- (NSUInteger)supportedInterfaceOrientations { return self.topViewController.supportedInterfaceOrientations; } @end
bubuko.com,布布扣

需要旋转的ViewController设置

bubuko.com,布布扣
 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
    return YES;
}

- (BOOL)shouldAutorotate
{
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskAll;
}
bubuko.com,布布扣

 

其他不需要旋转的 ViewController设置,建议添加BaseViewController统一控制

bubuko.com,布布扣
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (BOOL)shouldAutorotate
{
    return NO;
}
- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationPortrait;
}
bubuko.com,布布扣

ios 单个ViewController屏幕旋转,布布扣,bubuko.com

ios 单个ViewController屏幕旋转

原文:http://www.cnblogs.com/geweb/p/shouldAutorotate.html

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