iphone 恒屏和自动旋转

iphone 恒屏和自动旋转,第1张

概述利用系统自动生成的代码。 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {     // Return YES for supported orientations     return (interfaceOrientation == UIInterfaceO

利用系统自动生成的代码。

- (BOol)shouldautorotatetoInterfaceOrIEntation:(UIInterfaceOrIEntation)interfaceOrIEntation {
    // Return YES for supported orIEntations
    return (interfaceOrIEntation == UIInterfaceOrIEntationPortrait);//系统默认不支持旋转功能
}

要想让系统自动实现旋转功能仅需要实现上面的代码,把return (interfaceOrIEntation == UIInterfaceOrIEntationPortrait)修改成为return OK即可。

修改后的代码为:

- (BOol)shouldautorotatetoInterfaceOrIEntation:(UIInterfaceOrIEntation)interfaceOrIEntation {
    // Return YES for supported orIEntations
    return OK;
}

然后在使用自动调整属性设计界面(WIN+3),指定要支持的方向即可。(WIN键就是Ctrl和Alt键中间的键)

在使用模拟仿真器的时候,要让其自动旋转只需WIN+ ->(<-)即可。


下面是支持上下横屏的代码:

// OverrIDe to allow orIEntations other than the default portrait orIEntation.// This method is deprecated on ios6- (BOol)shouldautorotatetoInterfaceOrIEntation:(UIInterfaceOrIEntation)interfaceOrIEntation {    return UIInterfaceOrIEntationIsLandscape( interfaceOrIEntation );}// For ios6,use supportedInterfaceOrIEntations & shouldautorotate instead- (NSUInteger) supportedInterfaceOrIEntations{#ifdef __IPHONE_6_0    return UIInterfaceOrIEntationMaskLandscape;#endif}- (BOol) shouldautorotate {    return YES;}
总结

以上是内存溢出为你收集整理的iphone 恒屏和自动旋转全部内容,希望文章能够帮你解决iphone 恒屏和自动旋转所遇到的程序开发问题。

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

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

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

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

发表评论

登录后才能评论

评论列表(0条)

    保存