
如果需要获得UIDeviceOrientation的转换消息的话,只需要:
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIApplicationDidChangeStatusBarFrameNotification object:nil];
在结束时候,需要移除注册的通知(dealloc)
[[NSNotificationCenter defaultCenter] removeObserver:self]; [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
- (void)orientationChanged:(NSNotification *)notification { ... }