diff --git a/SIAlertView/SIAlertView.m b/SIAlertView/SIAlertView.m index 7a67df3..0d46a47 100644 --- a/SIAlertView/SIAlertView.m +++ b/SIAlertView/SIAlertView.m @@ -888,6 +888,20 @@ - (void)teardown self.titleLabel = nil; self.messageLabel = nil; [self.buttons removeAllObjects]; + + NSEnumerator *frontToBackWindows = [UIApplication.sharedApplication.windows reverseObjectEnumerator]; + + for (UIWindow *window in frontToBackWindows){ + BOOL windowOnMainScreen = window.screen == UIScreen.mainScreen; + BOOL windowIsVisible = !window.hidden && window.alpha > 0; + BOOL windowLevelNormal = window.windowLevel == UIWindowLevelNormal; + + if (windowOnMainScreen && windowIsVisible && windowLevelNormal) { + [window makeKeyAndVisible]; + break; + } + } + [self.alertWindow removeFromSuperview]; self.alertWindow = nil; self.layoutDirty = NO;