检查UIView是否显示UIAlertView [英] Check if UIView is displaying a UIAlertView

查看:147
本文介绍了检查UIView是否显示UIAlertView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以确定当前的UIView是否显示UIAlertView(而不是每次创建UIAlertView时都要设置变量).

Is it possible to determine if the current UIView has a UIAlertView on display (other than setting a variable every time a UIAlertView is created).

我在考虑

    if ([self.view.subviews containsObject:UIAlertView]) { ... }

但这显然行不通.

推荐答案

这不适用于iOS7及更高版本.

<罢工> [alertView Show] 我猜是在主窗口上添加了子视图.

[alertView Show] adds subview on main window I guess.

for (UIWindow* window in [UIApplication sharedApplication].windows){
    for (UIView *subView in [window subviews]){
        if ([subView isKindOfClass:[UIAlertView class]]) {
            NSLog(@"has AlertView");
        }else {
            NSLog(@"No AlertView");
        }
    }
}

这篇关于检查UIView是否显示UIAlertView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆