2010-09-22 155 views
0

这是从以前的问题,我问了一个延续:iPhone View StrategyiPhone视图不会旋转

我现在用下面的方法来视图之间切换:

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; 
} 

这已成为一个有点棘手的问题对我来说。有任何想法吗?

谢谢你,艾伦

+2

[完全重复](http://stackoverflow.com/questions/3773012/iphone-view-wont-rotate) – 2010-09-22 19:57:44

+0

对不起,删除了另一个! – 2010-09-22 20:23:08

+0

这不是切换视图的正常方式... – 2010-09-22 23:47:29

回答

0

你在那里拥有的UITabBarController?

+0

我没有使用UITabBarController。我只是自己使用视图控制器。 – 2010-09-22 20:24:34

0

shouldAutorotateToInterfaceOrientation方法应该在视图的当前视图控制器中,而不是在UIViews本身中。

+0

对不起,我正在谈论我的视图控制器而不是视图。我编辑了我的原始帖子。 – 2010-09-22 20:23:53

1

这可能是你如何展示你的观点。我遇到了显示模态窗口的popover问题。仍然不确定是什么导致了问题,认为这是一个苹果的错误。你为什么不尝试做这样的事情:

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

这是假设你gameViewController在代码初始化别的地方。不知道这是你在找什么,但它可能工作。