[英]iPhone view won't rotate
這是我之前提出的問題的延續: iPhone View Strategy
我現在使用以下方法在視圖之間切換:
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;
}
這對我來說已經成為一個症結所在。 有任何想法嗎?
謝謝,艾倫
這可能是您顯示視圖的方式。 我在顯示模式窗口的彈出窗口時遇到了這個問題。 仍然不確定是什么引起了該問題,請認為這是一個蘋果錯誤。 您為什么不嘗試做這樣的事情:
[window addSubview:gameViewController.view];
[window makeKeyAndVisible];
假設您的gameViewController已在代碼中的其他地方初始化。 不知道這是您要找的東西,但它可能有效。
你那里有UITabBarController嗎?
shouldAutorotateToInterfaceOrientation方法應該放在視圖的當前視圖控制器中,而不是UIViews本身。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.