当前位置: 首页 > 工具软件 > Popup View > 使用案例 >

dismiss all popup view

夏令秋
2023-12-01

可以遍历所有view, 如果是alert或sheet这类的弹出窗口,就自动让其关闭,代码片断如下:

- (void)dismissAllPopup:(NSArray *)subviews {
    Class alert = [UIAlertView class];
    Class sheet = [UIActionSheet class];
    for (UIView * subview in subviews){
        if ([subview isKindOfClass:alert]){
            [(UIAlertView *)subview dismissWithClickedButtonIndex:[(UIAlertView *)subview cancelButtonIndex] animated:NO];
        } else if ([subview isKindOfClass:sheet]){
            [(UIActionSheet *)subview dismissWithClickedButtonIndex:[(UIActionSheet *)subview cancelButtonIndex] animated:NO];
        } else {
            [self dismissAllPopup:subview.subviews];
        }
    }
}


 类似资料:

相关阅读

相关文章

相关问答