如何获取到当前界面的UIAlertView?

比如说当前界面有个弹窗,不知道它具体是哪个类?如何获取拿到这个弹窗的实例?

UIViewController* activityViewController()
{
UIViewController *appRootVC = [UIApplication sharedApplication].keyWindow.rootViewController;
UIViewController *topVC = appRootVC;
while (topVC.presentedViewController) {
topVC = topVC.presentedViewController;
}
if(topVC == nil) {
NSLog(@“find topvc fail”);
}
return topVC;
}

这样应该就可以了,拿到最顶层的view

1 个赞

可以看看我的回复:回复
基本如果是present的没问题,我试了一下 UIAlertController 的弹框,可以获取到控制器,然后根据view可以拿到其弹框view 。具体的弹框你可以试试看

1 个赞