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

来源:互联网 发布:俄罗斯社交软件 编辑:程序博客网 时间:2024/06/03 21:23

文章内的图片点击后需要单独显示出来,而且还需要支持横屏显示,也仅有这个界面支持横屏显示。

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;




0 0
原创粉丝点击