IOS横屏竖屏问题---1

IOS横屏竖屏问题---1,第1张

概述引言: iPhone的横屏竖屏针对iOS系统版本分为两种开发方式: 一种是iOS 6之前的使用模式 一种是iOS6的新模式. 两者的区别还是蛮大的. 参考: 1:IOS6屏幕旋转详解(自动旋转、手动旋转、兼容IOS6之前系统) http://blog.csdn.net/cococoolwhj/article/details/8208991 使用: 支持自动旋转? iOS6之前通常使用 should

引言:

iPhone的横屏竖屏针对iOS系统版本分为两种开发方式: 一种是iOS 6之前的使用模式 一种是iOS6的新模式. 两者的区别还是蛮大的.


参考:

1:IOS6屏幕旋转详解(自动旋转、手动旋转、兼容IOS6之前系统)

http://blog.csdn.net/cococoolwhj/article/details/8208991


使用:

支持自动旋转?

iOS6之前通常使用 shouldautorotatetoInterfaceOrIEntation 来单独控制某个UIVIEwController的方向,需要哪个vIEwController支持旋转,只需要重写shouldautorotatetoInterfaceOrIEntation方法。如下示例,设置以后,屏幕被旋转时只支持横屏转换:

[csharp]  view plain copy - (BOol)shouldautorotatetoInterfaceOrIEntation:(UIInterfaceOrIEntation)interfaceOrIEntation   {      return UIInterfaceOrIEntationIsLandscape(interfaceOrIEntation);   }  

iOS6之后使用如下两个方法控制自动旋转,分别是:

copy - (BOol)shouldautorotate       NSLog(@"让不让我旋转?");       return YES;   }      - (NSUInteger)supportedInterfaceOrIEntations {       NSLog(@"让我旋转哪些方向");       return UIInterfaceOrIEntationMaskAllButUpsIDeDown;   }  

那么在自动旋转触发后,系统会自动调用另外两个方法:

copy - (voID)willRotatetoInterfaceOrIEntation:(UIInterfaceOrIEntation)toInterfaceOrIEntation duration:(NSTimeInterval)duration {       [super willRotatetoInterfaceOrIEntation:toInterfaceOrIEntation duration:duration];       NSLog(@"将要旋转了?");   }      - (voID)dIDRotateFromInterfaceOrIEntation:(UIInterfaceOrIEntation)fromInterfaceOrIEntation {       [super dIDRotateFromInterfaceOrIEntation:fromInterfaceOrIEntation];       NSLog(@"如果让我旋转,我已经旋转完了!");          2:让程序第一次启动时立刻显示横屏还是竖屏的方式

此处

如果是iOS6之前,下面设置的设备支持方向可在应用里面再被修改

如果是iOS6以后,会做为硬性条件,也就是如果设置了以后,应用里面的代码也无法再使用这个方向


3:传说中的私有API实现切换VIEwController强制横屏的方式

copy if ([[UIDevice currentDevice] respondsToSelector:@selector(setorIEntation:)]) {           [[UIDevice currentDevice] performSelector:@selector(setorIEntation:)                                          withObject:(ID)UIInterfaceOrIEntationLandscapeRight];       }  
4:使用xib进行界面设计时,改变xib的横竖显示方式

总结

以上是内存溢出为你收集整理的IOS横屏竖屏问题---1全部内容,希望文章能够帮你解决IOS横屏竖屏问题---1所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/1088933.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-27
下一篇2022-05-27

发表评论

登录后才能评论

评论列表(0条)

    保存