Hey,
I've got a little problem using UIDeviceOrientationDidChangeNotification. After I leave a certain ViewController (the viewWillDisappear: method is called), the device won't stop to send notifications.
This means, after I pushed another ViewController on top of the stack and I rotate the device, the receivedRotate: method of the ViewController here will be called and that I don't want.
I can't find something in the documentation and on other topics in here as well. It would be great if someone could help.
My scenario is the following:
- (void)viewDidLoad {
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receivedRotate:) name:UIDeviceOrientationDidChangeNotification object:nil];
// other things...
}
Here the viewWillAppear: method
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
}
And last the viewWillDisappear: method
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
}
Thanks in advance!