How to remove _UIAlertNormalizingOverlayWindow

In my application, I need to remove any warnings visible in the window when the application switches to background.But the problem is that I do not want to reject it with

[alert dismissWithClickedButtonIndex:0 animated:YES]

because it will call the delegate clickedButtonAtIndexand call the method. I will not avoid this when the application goes into the background.

I did this successfully by removing alertView from the subViews of the windowusing 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 _UIAlertNormalizingOverlayWindow is still there, and this blocks Interaction.I user needs to remove _UIAlertNormalizingOverlayWindow from my window as well. Please help me do this or suggest any alternatives to reach a solution.

+5
source share
2 answers

Although this is not a very clean solution (ivar is assumed BOOL _backgroundAlertFlag

- (void)applicationDidEnterBackground:(UIApplication *)application {
    _backgroundAlertFlag = YES;

    // find your UIAlertView as you are doing already

    [alert dismissWithClickedButtonIndex:0 animated:NO];
    _backgroundAlertFlag = NO;
}

Then in your method UIAlertViewDelegate:

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
    if( !_backgroundAlertFlag )
    {
        // handle alert processing normally here
    }
    // other wise ignore (just dismiss)
}
+3
source

As far as I could tell, there is no way to remove UIWindows. The only thing you can do is make another window key and be visible.

0
source

All Articles