关于屏幕旋转

作者: 石丘 | 来源:发表于2015-07-31 11:34 被阅读319次

重新整理了下老博客
需求:全局主要是竖屏 个别界面需要横屏

一.前往TARGETS
找到TARGETS->General->点掉 Landscape

这边如果是做的通用版 需要把 Universal ipone ipad 挨个点开勾选一遍

二.前往plist
找到plist文件 在Supported interface 里面把横屏的Item点掉
3.找到需要设置横屏的控制器添加以下代码

<code>
-(BOOL)shouldAutorotate{
return NO;//有些情况这里是YES
}
-(NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskLandscapeRight;
}
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
return UIInterfaceOrientationLandscapeRight;
}
</code>

这种方法的使用前提
1.当前viewControllerwindowrootViewController
2当前viewControllermodal模式的 即viewController是调用presentModalViewController而显示出来的

以上三个方法的补充说明:
-(BOOL)shouldAutorotate;
配置视图旋转设置
返回一个布尔值,该值指示视图控制器的内容是否��应该自动旋转。
如果为真内容应该旋转 否则假 默认值为真。
-(NSUInteger)supportedInterfaceOrientations;
返回控制器支持的所有视图方向
当用户更改设备方向,系统在根视图控制器或顶部视图控制器 调用此方法 模态出新的视图控制器。
如果视图控制器支持新的方向,窗口和视图控制器将旋转到新的方向。这个方法只有在视图控制器的��shouldAutorotate方法返回值为真时才会调用(这个表示疑惑 我就是在返回NO时调用的)。
重写这个方法 告诉视图控制器需要支持的所有方向。
一个视图控制器支持的��窗口方向的默认值 在iPad中设置为UIInterfaceOrientationMaskAll,在 iPhone中设置为UIInterfaceOrientationMaskAllButUpsideDown

没看明白 当视图控制器的支持方向和app支持的方向交叉时候 是怎么决定方向的
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation;

Returns the interface orientation to use when presenting the view controller.

当使用模态视图控制器时 返回界面使用方向

The system calls this method when presenting the view controller full screen. You implement this method when your view controller supports two or more orientations but the content appears best in one of those orientations.

当模态到一个全屏视图控制器时系统调用此方法。你实现这个方法当 你的视图控制器支持两个或两个以上的方向 但是在显示内容最好的其中一个方向出现。

If your view controller implements this method, then when presented, its view is shown in the preferred orientation (although it can later be rotated to another supported rotation). If you do not implement this method, the system presents the view controller using the current orientation of the status bar.

如果你的视图控制器实现了该方法,然后模态视图时,其视图所示择优取向(尽管它以后可以旋转到另一个支持旋转)。如果你不实现这个方法,系统在模态到一个新的视图控制器时将使用当前状态栏的取向。

http://www.cnblogs.com/smileEvday/archive/2013/04/24/Rotate2.html 这篇写的不错 mark一下

相关文章

  • 关于屏幕旋转

    重新整理了下老博客需求:全局主要是竖屏 个别界面需要横屏 一.前往TARGETS 这边如果是做的通用版 需要把 U...

  • 关于iOS屏幕旋转

    在iOS开发中,最常见的屏幕旋转方案: 取消Device Orientation的选择按钮取消选中 在appDel...

  • iOS屏幕旋转中的坑

    屏幕旋转是个坑 最近做的项目中有不少地方遇到了需要旋转屏幕的地方,在屏幕旋转的大坑里挣扎了一番,发现网上很多关于屏...

  • iOS 关于屏幕旋转问题

    关于屏幕旋转需要理解两个概念设备方向(UIDeviceOrientation)和屏幕方向(UIInterfaceO...

  • 开发记录小问题

    一、关于屏幕旋转的监听UIDevice.orientationDidChangeNotification 通知当设...

  • 关于屏幕旋转中 UICollectionViewFlowLayo

    遇到坑了。 -(void)willRotateToInterfaceOrientation:(UIInterfac...

  • iOS 关于屏幕旋转shouldAutorotate

    iOS中关于shouldAutorotate(屏幕旋转的问题); 在这之前必须在你的Info里面配置你的支持方向信...

  • 关于iOS屏幕旋转处理

    首先Device orientation中要配置支持方向其次关键方法如下:1.是否支持自动旋转 (BOOL)sho...

  • iOS 横竖屏切换

    网上关于横竖屏切换的资料很多,但是很容易踩到坑,不是屏幕不旋转,就是屏幕旋转后没有状态栏等,在写的小demo里屏幕...

  • iOS 屏幕旋转

    屏幕旋转 认知 期望达到的目的 如何让App支持屏幕旋转 如何让App屏幕旋转 如何保证屏幕旋转后布局不会乱 总结...

网友评论

    本文标题:关于屏幕旋转

    本文链接:https://www.haomeiwen.com/subject/zvxvqttx.html