The functionality related to "UIDeviceOrientationDidChangeNotification" causes a crash.
x1024 opened this issue · 2 comments
I experienced a crash when removing EAIntroView from the view hierarchy.
The problem was that I was removing the whole UIViewController that EAIntroView was part of, instead of calling "hideWithFadeOutDuration:". The crash happened because these two lines weren't being called:
[[NSNotificationCenter defaultCenter] removeObserver:self];
[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
It was pretty surprising to see that "beginGeneratingDeviceOrientationNotifications" was being called in the constructor of EAIntroView.
I would expect that calling a constructor doesn't change any global state at all.
(Not to mention that the opposite action isn't called in a "destructor", meaning that the effects aren't always properly reversed).
My suggestion is: The code with side effects should be moved into the willMoveToSuperview: method of EAIntroPage. If the suggestion gets approved, I can implement & test that.
Good catch, thanks for detailed research on this.
I agree with your suggestion and will be happy to see PR.
I reproduced the crash on iOS8 (in iOS9 observers are stored as weak references, and are automatically cleaned up).
With this fix, the crash no longer happens.
- Tested by adding the EAIntroView to a superview, moving it to a different superview, then removing it from the view hierarchy.
- Tested with an EAIntroView in a storyboard.