iPhone 视图不会旋转
这是我问的上一个问题的延续: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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这可能是您表达观点的方式。我在显示模式窗口的弹出窗口时遇到了这个问题。仍然不确定是什么导致了这个问题,认为这是一个苹果错误。你为什么不尝试做这样的事情:
这是假设你的 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:
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.
你那里有 UITabBarController 吗?
do you have UITabBarController in there?
shouldAutorotateToInterfaceOrientation 方法应该进入视图的当前视图控制器,而不是 UIView 本身。
The shouldAutorotateToInterfaceOrientation method should go in the current view controller for the views, not the UIViews themselves.