ALAlertBanner
ALAlertBanner copied to clipboard
Listen for UIApplicationDidChangeStatusBarOrientationNotification instead of UIDeviceOrientationDidChangeNotification
ALAlertBanner listens for UIDeviceOrientationDidChangeNotification
to handle rotation events. I'd prefer to listen for UIApplicationDidChangeStatusBarOrientationNotification
instead but I need the bounds of the banner's superview to update before handling the rotation notification, and the only way to that seems to be by using UIDeviceOrientationDidChangeNotification
.
You could use KVO to observe the superview's frame and layout whenever it changes...
Good suggestion. I'll give it a shot. Thanks!
@ryanpeggs, take a look at this commit: e15cfacfc75981794afb66deef0cc7de2e0ede5d
I switched over to KVO but there's a problem with monitoring the view's frame. Because the navigation bar resizes itself when going between landscape and portrait, it causes observeValueForKeyPath:
to fire multiple times, which messes up the banner if it's in the middle of an animation (doesn't really "mess it up" but basically just makes it snap to it's final location without animating the rest of the transition). I don't know if it's going to be feasible to use KVO unless i can refactor the code to deal with this issue.
And this post on StackOverflow makes me think it's best to not use KVO at all...
I suppose I could always add a frame-changed-notifier method to put in the view controller's willAnimateRotationToInterfaceOrientation:
and make it mandatory to implement or something like that... but that feels like it's getting messy.