У меня есть класс Utils, который показывает UIAlertView при запуске определенных уведомлений. Есть ли способ отклонить любые открытые UIAlertViews перед тем, как показать новый?
В настоящее время я делаю это, когда приложение входит в фоновый режим, используя
[self checkViews:application.windows];
на applicationDidEnterBackground
- (void)checkViews:(NSArray *)subviews {
Class AVClass = [UIAlertView class];
Class ASClass = [UIActionSheet class];
for (UIView * subview in subviews){
if ([subview isKindOfClass:AVClass]){
[(UIAlertView *)subview dismissWithClickedButtonIndex:[(UIAlertView *)subview cancelButtonIndex] animated:NO];
} else if ([subview isKindOfClass:ASClass]){
[(UIActionSheet *)subview dismissWithClickedButtonIndex:[(UIActionSheet *)subview cancelButtonIndex] animated:NO];
} else {
[self checkViews:subview.subviews];
}
}
}
Это упрощает работу с applicationDidEnterBackground, поскольку я могу использовать application.windows
Можно ли использовать AppDelegate или что-то подобное, чтобы получить все представления, пропустить их и убрать любые UIAlertViews?