2011-03-14 59 views
1

我試圖通知我的UIViewController按設備方向重新應用佈局。爲此,我將UIDeviceOrientationDidChangeNotification發佈到默認中心。它的工作,但沒有旋轉動畫。我認爲我有些失蹤。我如何正確地發帖UIDeviceOrientationDidChangeNotification如何正確發佈`UIDeviceOrientationDidChangeNotification`?

回答

0

我不認爲應該有任何東西,當你嘗試發佈。 取而代之的是,當方向改變時它會自動發佈。如果你想使用它,你應該添加一個觀察者帽子通知。

+0

我試圖模擬UI的方向變化... – Eonil 2011-03-21 02:12:09

1

用途:

[[UIApplication sharedApplication] setStatusBarOrientation: UIInterfaceOrientationLandscapeRight animated:YES]; 

代替(替換LandscapeRight需要的話),因爲你不應該發佈的系統通知。

1

它將發佈的事件對你:

- (void)updateOrientation 
{ 
    [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications]; 
    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; 
} 

但是,當然,你應該更整潔,並呼籲[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications]當你需要停止旋轉,然後調用[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];當你準備好來處理它再次:它會調用您的視圖控制器的所有必要的回調。