In my application I need to remove any alerts visible in the window, when the app goes to background.But the problem is that, I don’t want to dismiss it with
[alert dismissWithClickedButtonIndex:0 animated:YES]
because, it will trigger the clickedButtonAtIndex Delegate and will invoke a method.I wan’t to avoid this when app goes to background.
I did it successfully by removing the alertView from the subViews of window using the following code
for (UIWindow *window in [UIApplication sharedApplication].windows) {
for (UIView *view in [window subviews]) {
if ([view isKindOfClass:[UIAlertView class]]) {
[view removeFromSuperview];
}
}
But the problem is that the _UIAlertNormalizingOverlayWindow is still there and it blocks the user Interaction.I need to remove the _UIAlertNormalizingOverlayWindow also from my window.
Please help me to do this or please suggest any alternatives to achieve the solution .
Although it’s not a very clean solution (assumes ivar
BOOL _backgroundAlertFlagThen in your
UIAlertViewDelegatemethod: