【问题标题】:IOS 6 Storyboard rotation doesn't work as expectedIOS 6 Storyboard 旋转无法按预期工作
【发布时间】:2013-05-27 07:45:59
【问题描述】:

我正在开发带有情节提要的 iOS6 应用程序,但遇到了意想不到的行为。 我的应用程序几乎处于纵向模式,我会在除两个视图之外的所有视图中保持此方向。因此,该项目同时支持横向和纵向模式,我将导航控制器子类化为一个类别(几乎无处不在 :-)在 Appdelegate.m 中,每个视图控制器都实现了

- (NSUInteger)supportedInterfaceOrientations{
 return UIInterfaceOrientationMaskPortrait; (landscape where needed)
}

-(BOOL)shouldAutorotate{
return YES;
}

除了在横向视图到纵向视图之间的过渡(反​​之亦然?)之外,一切似乎都运行良好,UI 的所有元素都以横向显示(想象一下你保持手机水平),如果您转动手机,将触发旋转事件,用户界面会以纵向返回,并且现在才锁定到该方向。有没有办法在视图出现之前触发旋转? 为什么在 ViewWillAppear 阶段不调用 shouldAutorotate?

谢谢!

【问题讨论】:

标签: iphone objective-c ios6 storyboard navigationcontroller


【解决方案1】:

删除上述两个功能并尝试它应该可以工作

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
         Return YES for supported orientations

    }

如果仍然无法正常工作,请尝试更改 appDelegate

[window addSubview:nav.view];

到这个代码

 window.rootViewController=nav;

【讨论】:

  • 我已经删除了 AppDelegate.m 中的函数和定义,但是这个函数永远不会被调用,并且 ui 没有锁定到所需的方向。
【解决方案2】:

我发现这个在线章节非常适合解释 UIViewControllers 和旋转。

http://www.apeth.com/iOSBook/ch19.html#Rotation

这是一个大页面,向下滚动到旋转。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-06-01
    • 1970-01-01
    • 2017-02-17
    • 2015-01-11
    • 1970-01-01
    • 2021-08-13
    • 1970-01-01
    相关资源
    最近更新 更多