I have a little problem using UIDeviceOrientationDidChangeNotification. After I left a specific ViewController (the viewWillDisappear :) method is called, the device will not stop sending notifications.
This means that after I clicked another ViewController on top of the stack and I turned the device, the receivedRotate method will be called here: the ViewController method, which I do not need.
I can not find something in the documentation and on other topics here. It would be great if someone could help.
My scenario is as follows:
- (void)viewDidLoad { [super viewDidLoad]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receivedRotate:) name:UIDeviceOrientationDidChangeNotification object:nil];
Here viewWillAppear: method
- (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; }
And the last: viewWillDisappear: method
- (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications]; }
Thanks in advance!
source share