您的位置:首页 > 移动开发 > IOS开发

NT_iOS笔记—iOS图片显示2_某一个界面支持横屏()

2014-10-20 14:57 447 查看
文章内的图片点击后需要单独显示出来,而且还需要支持横屏显示,也仅有这个界面支持横屏显示。

1.添加支持的方向

General—>Deployment info—>Device Orientation



2.创建继承UINavigationController的子类并添加如下方法:

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

- (NSUInteger)supportedInterfaceOrientations
{
return self.topViewController.supportedInterfaceOrientations;
}


3.在不需要支持横屏显示的界面添加如下方法(iOS6以上):

-(BOOL)shouldAutorotate
{
return NO;
}

-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}


4.在需要支持横屏的界面修改上面的方法即可。
5.由于横竖屏的切换,界面需要重新绘画,可以在如下方法中进行(iOS6以上):

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐