0

调用未进入 UIInterfaceOrientation 委托方法请帮助

这是代码

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
    return YES;
}

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    if (toInterfaceOrientation == UIInterfaceOrientationPortrait)
    {
        NSLog(@"potrait");
    }
    else
    {

    }
}
4

2 回答 2

4

您的视图控制器是否在另一个视图控制器中?

寻找 技术问答 QA1688 为什么我的 UIViewController 不会随设备旋转?在您的开发者文档中

这会给你一个提示,为什么它在你的情况下不起作用。

于 2011-02-09T13:39:01.740 回答
1

上周我遇到了这个问题,这就是我发现的。如果您使用的是标签栏,那么您必须有

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
    return YES;
}

在添加到 TabBarController 的每个视图控制器中,以便它们中的任何一个旋转。如果您只希望某些选项卡旋转,您仍然可以通过添加

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
}

如果您使用的是 NavigationController,可能会有类似的解决方案,但我还没有遇到这个问题。

于 2011-02-09T13:38:38.090 回答