iOS 各种设备 plus 横屏问题。
来源:互联网 发布:文字修改软件 编辑:程序博客网 时间:2024/05/16 14:48
今天在做到横屏处理的问题时,因为内容较多,所以特整理下来,跟大家分享。有问题,大家评论中交流。
ios 横屏问题大致分为两种 window 级别的控制 和 controller级别的控制
一、windows级别的控制
在appdelegate中如下方法,即可声明应用支持的方向。
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
返回参数为
typedef NS_OPTIONS(NSUInteger, UIInterfaceOrientationMask) { UIInterfaceOrientationMaskPortrait = (1 << UIInterfaceOrientationPortrait), UIInterfaceOrientationMaskLandscapeLeft = (1 << UIInterfaceOrientationLandscapeLeft), UIInterfaceOrientationMaskLandscapeRight = (1 << UIInterfaceOrientationLandscapeRight), UIInterfaceOrientationMaskPortraitUpsideDown = (1 << UIInterfaceOrientationPortraitUpsideDown), UIInterfaceOrientationMaskLandscape = (UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight), UIInterfaceOrientationMaskAll = (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortraitUpsideDown), UIInterfaceOrientationMaskAllButUpsideDown = (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight),};这个方法与info.plist 和 targets-general 中对应的设置,功能是一样的。
二、Controller层面的控制。
基本方法有四个
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{ return toInterfaceOrientation != UIInterfaceOrientationMaskPortrait;}- (BOOL)shouldAutorotate{ return NO;}- (NSUInteger)supportedInterfaceOrientations{ return UIInterfaceOrientationMaskPortrait;}- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{ return UIInterfaceOrientationPortrait;}
当然,仅仅把这几个方法写到相应的controller中有些时候是没有用的。
这些特殊情况就是当你使用TabbarController和NavigationController按照如上做法使用的时候。
办法就是继承TabbarController和NavigationController,并添加上述几个方法。
好吧。如果用的是系统的 TabbarController和NavigationController 最好的方法是:“重写”。。。。
0 0
- iOS 各种设备 plus 横屏问题。
- iOS区分各种设备
- ios 获取设备各种信息
- iOS---获取设备各种信息
- 常用 iOS各种问题
- IOS各种编译问题
- IOS获取设备类型 (更新添加iPhone6 & iPhone6 Plus)
- ios 获取设备型号 最新(包含iphone6 and 6 plus)
- iOS各种设备信息获取总结
- iOS 如何获取设备的各种信息
- iOS 获取设备的各种信息
- iOS 如何获取设备的各种信息
- iOS 获取设备的各种信息
- iOS系统的各种设备识别码
- iOS 如何获取设备的各种信息
- 最全最新获取各种设备号 (含iphone6,iphone6 plus)
- ios-ios各种设备的尺寸和分辨率
- ios,设备标签与设备型号的对应关系(包含6plus)
- spark中的aggregate action的实现过程
- 高斯日记
- Java获取客户端IP
- NPM小结
- swfupload2_2上传视频的实现
- iOS 各种设备 plus 横屏问题。
- Struts 2 值栈
- android开发-写个扫雷玩玩
- 设置UITextField的内间距
- [问题记录]No known instance method for selector 'respondsToSelector:'
- 一起学android之自定义控件一起制作自定义标签(39)
- 将Vim改造为强大的IDE—Vim集成Ctags/Taglist/Cscope/Winmanager/NERDTree/OmniCppComplete(有图有真相)
- android 网络编程 HttpGet类和HttpPost类使用详解
- SVG滤镜:feComponentTransfer