2011-03-14 57 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];当你准备好来处理它再次:它会调用您的视图控制器的所有必要的回调。