我正在尝试为我的某个视图处理viewcontroller上的设备方向更改。 这里是我的代码:UIDeviceOrientationDidChangeNotification只会触发一次
- (void)viewDidLoad {
[super viewDidLoad];
NSLog(@"viewDidLoad");
// Tell the UIDevice to send notifications when the orientation changes
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:nil];
}
// tell the director that the orientation has changed
- (void) orientationChanged:(NSNotification *)notification
{
NSLog(@"orientationChanged");
}
当我第一次启动应用程序时,orientationChanged选择被调用,但在此之后,它不会再次呼吁无论多少我旋转的iPad。有谁知道我可能做错了什么?当我在应用程序委托中放置类似的代码时,它可以正常工作,但在这个特定的视图控制器中,它并不适合。
shouldAutorotateToInterfaceOrientation用于自动旋转视图。我不希望视图自动旋转。我只想接收设备旋转时间的通知。 – MrPrezident 2011-04-17 19:15:42