iPhone 视图不会旋转

发布于 2024-09-24 16:43:30 字数 788 浏览 3 评论 0原文

这是我问的上一个问题的延续:iPhone 查看策略

我现在使用以下方法在视图之间切换:

UIWindow *window = [[UIApplication sharedApplication] keyWindow];
[window setRootViewController:[self gameViewController]];
[[[self gameViewController] view] becomeFirstResponder];

我遇到的问题是我的视图都没有正确旋转(状态栏旋转但没有其他旋转)。初始视图很好,但我使用上述方法导航到的任何视图都存在旋转问题。

我在所有视图控制器中实现了 shouldAutorotateToInterfaceOrientation 方法,如下所示:

// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES to allow autorotation
    return YES;
}

这对我来说是一个症结所在。有什么想法吗?

谢谢, 艾伦

This is a continuation from a previous question that I asked: iPhone View Strategy

I am now using the following method to switch between views:

UIWindow *window = [[UIApplication sharedApplication] keyWindow];
[window setRootViewController:[self gameViewController]];
[[[self gameViewController] view] becomeFirstResponder];

The problem I am having is that none of my views rotate properly (the status bar rotates but nothing else). The initial view is fine but any views that I navigate to using the above method have the problem with rotation.

I have implemented the shouldAutorotateToInterfaceOrientation method in all of my view controllers as follows:

// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES to allow autorotation
    return YES;
}

This has become a bit of a sticking point for me. Any ideas?

Thanks,
Alan

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

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

发布评论

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

评论(3

那小子欠揍 2024-10-01 16:43:30

这可能是您表达观点的方式。我在显示模式窗口的弹出窗口时遇到了这个问题。仍然不确定是什么导致了这个问题,认为这是一个苹果错误。你为什么不尝试做这样的事情:

[window addSubview:gameViewController.view];
[window makeKeyAndVisible];

这是假设你的 gameViewController 是在代码中的其他地方初始化的。不确定这是否是您正在寻找的,但它可能有效。

It might be how you are displaying your views. I was having this problem with a popover that was displaying a modal window. Still not sure what was causing the problem, think it was an apple bug. Why don't you try doing something like this:

[window addSubview:gameViewController.view];
[window makeKeyAndVisible];

This is assuming that your gameViewController is initialized somewhere else in your code. Not sure if that is what you are looking for but it may work.

自在安然 2024-10-01 16:43:30

你那里有 UITabBarController 吗?

do you have UITabBarController in there?

别挽留 2024-10-01 16:43:30

shouldAutorotateToInterfaceOrientation 方法应该进入视图的当前视图控制器,而不是 UIView 本身。

The shouldAutorotateToInterfaceOrientation method should go in the current view controller for the views, not the UIViews themselves.

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