iOS 横屏竖屏开发相关
来源:互联网 发布:软件测试总结报告 编辑:程序博客网 时间:2024/06/05 16:00
引言:
iPhone的横屏竖屏针对iOS系统版本分为两种开发方式: 一种是iOS 6之前的使用模式 一种是iOS6的新模式. 两者的区别还是蛮大的.
参考:
1:IOS6屏幕旋转详解(自动旋转、手动旋转、兼容IOS6之前系统)
http://blog.csdn.net/cococoolwhj/article/details/8208991
使用:
支持自动旋转?
iOS6之前通常使用 shouldAutorotateToInterfaceOrientation 来单独控制某个UIViewController的方向,需要哪个viewController支持旋转,只需要重写shouldAutorotateToInterfaceOrientation方法。如下示例,设置以后,屏幕被旋转时只支持横屏转换:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{ return UIInterfaceOrientationIsLandscape(interfaceOrientation);}
iOS6之后使用如下两个方法控制自动旋转,分别是:
- (BOOL)shouldAutorotate{ NSLog(@"让不让我旋转?"); return YES;}- (NSUInteger)supportedInterfaceOrientations { NSLog(@"让我旋转哪些方向"); return UIInterfaceOrientationMaskAllButUpsideDown;}
那么在自动旋转触发后,系统会自动调用另外两个方法:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration]; NSLog(@"将要旋转了?");}- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { [super didRotateFromInterfaceOrientation:fromInterfaceOrientation]; NSLog(@"如果让我旋转,我已经旋转完了!"); }
2:让程序第一次启动时立刻显示横屏还是竖屏的方式
此处
3:传说中的私有API实现切换ViewController强制横屏的方式
if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) { [[UIDevice currentDevice] performSelector:@selector(setOrientation:) withObject:(id)UIInterfaceOrientationLandscapeRight]; }
4:使用xib进行界面设计时,改变xib的横竖显示方式
- iOS 横屏竖屏开发相关
- iOS 横屏竖屏开发相关
- ios开发相关网址
- IOS开发相关资料
- ios 开发相关博客
- IOS 日历相关开发
- ios 图像开发相关
- ios越狱开发相关
- iOS开发相关网址
- iOS开发相关资源
- iOS 开发相关网址
- IOS 开发,定位相关
- iOS 开发相关
- IOS开发相关链接
- iOS开发-UITextField相关
- iOS开发 - 音频相关
- iOS开发笔记--keyboard相关
- 【iPone(iOS)相关开发】
- java连接数据库
- 名词解释:PCM、a率、u率
- Linux设备驱动程序学习
- 中国互联网盈利模式分析
- 离开后,别说祝我幸福
- iOS 横屏竖屏开发相关
- 85000只Pebble智能手表销售一空 融资额已破千万美元
- 关于ASP.NET页面打印技术的总结
- android性能测试工具之dumpsys
- Linux设备驱动程式学习(0) -Hello, world!模块
- 一个java程序的virtual memory 和 resident memory
- Hessian 简介
- Linux设备驱动程式学习(1)-字符设备驱动程式
- mcc出错的函数