When a warning appears, it will be moved to _UIAlertOverlayWindow. Therefore, a rather fragile method is to iterate over all windows and check if there are any UIAlertView routines.
-(BOOL)checkAlertViewVisibleStatus { for (UIWindow* window in [UIApplication sharedApplication].windows) { NSArray* subviews = window.subviews; if ([subviews count] > 0) if ([[subviews objectAtIndex:0] isKindOfClass:[UIAlertView class]]) return YES; } return NO; }
This is undocumented as it depends on the hierarchy of the internal view, although Apple cannot complain about it. A more reliable but even more undocumented method is to verify that `
[_ UIAlertManager visibleAlert]
`is zero.
These methods cannot check if the UIAlertView is displayed from SpringBoard.
Kanhaiya sharma
source share