ALAlertBanner
ALAlertBanner copied to clipboard
Interrupted animation leads to top navigation bar 'deadlock'
I'm experiencing a deadlock-like issue using ALAlertBanner in my iOS app. If I send the app to background while ALAlertBanner is displayed (but before it disappears), and then bring the app back into foreground, the banner disappears rather quickly, and then the app's top navigation bar stops to respond to user interactions (i.e. tapping on buttons won't work). The only way to get the top navigation bar back to work is to kill the app.
After I put in some logs here and there, I noticed that when this issue happens, the corresponding instance of ALAlertBanner is never released. After some more experiments, I find that animationDidStop:(CAAnimation *)animo finished:(BOOL)flag
is called with flag
set to NO
when the issue happens. So my temp workaround is to remove the check of && flag
so that the banner can still proceed to hide itself in such an event.
I think the core of the issue is, iOS appears to be in the habit of canceling a scheduled core animation when the app goes into background. When this happens, an animation receives an animationDidStop:finished:
event with the last parameter set to NO instead of YES.
Please let me know if there's anything else that I can provide. Thanks!
Lots of good info here, thanks!
Unfortunately, that flag
check is needed when dealing with orientation changes while a banner(s) is being animated, so removing it might cause more problems than it fixes. I think the best solution here would be to force hide any open banners before backgrounding your app via forceHideAllAlertBannersInView:
.
I would prefer to handle "forced" dismissal of banners in a cleaner manner, which would hopefully help in this situation. I've been busy recently with other projects but that is on my radar :)