无法旋转视图

发布于 2025-01-04 06:40:43 字数 620 浏览 2 评论 0原文

我正在使用 Xcode 4.2 开发故事板应用程序。

我正在尝试旋转视图,但它不起作用。我确保该应用程序支持摘要以及“信息”部分中的 4 次旋转。

我有两种受支持的方向:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    if (UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad) { //check if device is iPad
        return YES;
    }
    else
        return NO;
}

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

在 iPhone 模拟器上尝试过,它不起作用,但对于 iPad,它工作得很好......有什么原因吗?

我正在使用选项卡栏视图控制器,如果这有什么区别的话......

I am using Xcode 4.2 to develop a storyboard application.

I am trying to rotate views but it is not working. I made sure that the app supports the 4 rotations in the summary as well as in the "info" section.

I have two types of supported orientations:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    if (UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad) { //check if device is iPad
        return YES;
    }
    else
        return NO;
}

and

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

I tried it on the iPhone simulator and it is not working, but for the iPad it works perfectly fine... any reasons?

I am using a Tab Bar view controller if this makes any difference ...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

扬花落满肩 2025-01-11 06:40:43

来自文档

UITabBarController 中的所有子视图控制器或
UINavigationController 不同意共同的方向集。到
确保所有子视图控制器都正确旋转,您
必须为每个视图实现shouldAutorotateToInterfaceOrientation
代表每个选项卡或导航级别的控制器。每个人都必须同意
在发生旋转的同一方向上。也就是说,他们都
对于相同的方向位置应返回 YES。

因此,请确保标签栏控制器中的所有视图控制器都为 shouldAutorotateToInterfaceOrientation: 返回 YES

from this document

All child view controllers in your UITabBarController or
UINavigationController do not agree on a common orientation set. To
make sure that all your child view controllers rotate correctly, you
must implement shouldAutorotateToInterfaceOrientation for each view
controller representing each tab or navigation level. Each must agree
on the same orientation for that rotate to occur. That is, they all
should return YES for the same orientation positions.

so make sure all view controller in your tab bar controller return YES for shouldAutorotateToInterfaceOrientation:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文