2010-09-22 170 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在代碼初始化別的地方。不知道這是你在找什麼,但它可能工作。