xcode – iOS6中的纵向和横向模式

xcode – iOS6中的纵向和横向模式,第1张

概述将我的应用程序更新为iOS6标准时,纵向/横向消失了.当我使用 Xcode 3构建时,Ir工作得很好.但是现在使用最新的Xcode和最新的SDK,旋转消失了,它始终处于纵向模式.无论我在“支持的界面方向”中加入什么.我以前用来获得旋转的代码似乎根本没有效果. 我有这些台词. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOri 将我的应用程序更新为iOS6标准时,纵向/横向消失了.当我使用 Xcode 3构建时,Ir工作得很好.但是现在使用最新的Xcode和最新的SDK,旋转消失了,它始终处于纵向模式.无论我在“支持的界面方向”中加入什么.我以前用来获得旋转的代码似乎根本没有效果.
我有这些台词.

- (BOol)shouldautorotatetoInterfaceOrIEntation:(UIInterfaceOrIEntation)toInterfaceOrIEntation{    switch (toInterfaceOrIEntation) {        case UIInterfaceOrIEntationPortrait:        case UIInterfaceOrIEntationLandscapeleft:        case UIInterfaceOrIEntationLandscapeRight:            return YES;        default:            return NO;    }}

我如何更改以及如何更改以使其再次运行?

解决方法 首先,在AppDelegate中,写下这个.这是非常重要的

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrIEntationsForWindow:(UIWindow *)window{     return (UIInterfaceOrIEntationMaskAll);}

然后,对于只需要PORTRAIT模式的UIVIEwControllers,编写这些函数

- (BOol)shouldautorotate{     return YES;}- (NSUInteger)supportedInterfaceOrIEntations{     return (UIInterfaceOrIEntationMaskPortrait);}

对于也需要LANDSCAPE的UIVIEwControllers,将掩码更改为All.

- (NSUInteger)supportedInterfaceOrIEntations{    return (UIInterfaceOrIEntationMaskAllButUpsIDeDown);    //OR return (UIInterfaceOrIEntationMaskAll);}

现在,如果要在OrIEntation更改时进行一些更改,请使用此功能.

- (voID)willRotatetoInterfaceOrIEntation:(UIInterfaceOrIEntation)toInterfaceOrIEntation duration:(NSTimeInterval)duration{}

编辑:

很大程度上取决于你的UIVIEwController嵌入哪个控制器.

例如,如果它在UINavigationController中,那么您可能需要将UINavigationController子类化为覆盖这样的方向方法.

子类化UINavigationController(层次结构的顶层视图控制器将控制方向.)确实将其设置为self.window.rootVIEwController.

- (BOol)shouldautorotate {     return self.topVIEwController.shouldautorotate; } - (NSUInteger)supportedInterfaceOrIEntations {     return self.topVIEwController.supportedInterfaceOrIEntations; }

从iOS 6开始,UINavigationController不会要求其UIVIEwControllers提供方向支持.因此我们需要将其子类化.

总结

以上是内存溢出为你收集整理的xcode – iOS6中的纵向和横向模式全部内容,希望文章能够帮你解决xcode – iOS6中的纵向和横向模式所遇到的程序开发问题。

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

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

原文地址: http://outofmemory.cn/web/1054229.html

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

发表评论

登录后才能评论

评论列表(0条)

保存