2011-11-28 138 views
3

我的主UIViewController覆蓋willRotateToInterfaceOrientation:duration:以使背景視圖適應正確的方向。這在視圖內停留時工作正常。willRotateToInterfaceOrientation:持續時間:解除模態後不需要調用iOS5

但在我的應用程序中,某些用戶操作的結果可能導致呈現另一個「女兒」UIViewController。當用戶完成該女兒的UIViewController時,她通常返回到主視圖控制器。我的代碼呼叫dismissModalViewControllerAnimated:這樣做。

當用戶在屏幕上顯示女兒UIViewController時更改iPad方向時,會發生此問題。然後,主UIViewController將永遠不會看到willRotateToInterfaceOrientation:duration:的任何調用,並且其背景視圖將不正確。

這種設置在iOS 4的正常工作:在iOS 4的實施dismissModalViewControllerAnimated:電話UIWindow_setRotatableClient:toOrientation:updateStatusBar:duration:force:這就要求willRotateToInterfaceOrientation:duration:UIViewController的切換。

顯然,這種行爲改變爲iOS 5

我怎麼有望實現的方向變化,而我的觀點的iOS5下是關閉屏幕?例如,我應該在viewWillAppear:中查詢當前的方向嗎?我這樣做了,它可以解決這個問題,但我可能錯過了一些東西。

回答

2

嘗試通過通知中心這樣的處理界面變化:

[[NSNotificationCenter defaultCenter] addObserver:self 
             selector:@selector(orientationChanged:) 
              name:UIDeviceOrientationDidChangeNotification 
              object:nil]; 

而在「orientationChanged」方法

+0

很好的提示做界面相關的東西。我花了一個小時弄清楚爲什麼willRotateToInterfaceOrientation:持續時間不適用於iOS5,但在iOS6中起作用。 – TK189

+0

如果事情需要在輪換髮生之前完成,這並沒有幫助。 – jarryd

相關問題