简体   繁体   中英

iOS - Detect when an alertview appears on screen

Is there any way to figure-out in presented view controller when some alertview appears on screen from some other controller. I do not want to pass any block, delegate or fire any notification.

I dont understand, aren't you supposed to have to call [alertView show] in order for the alertView to show? so why would you need some extra mechanism to detect this event?

I don't have mac now. I'm posting it from windows machine. So i could not able to check whether its perfect code or not.
When UIAlertView is presented, it'll be presented as another UIWindow . So you can check it with UIApplication singleton methods. Like

UIAlertview *secondWindowisThere  = [[[UIApplication sharedApplication] windows] objectAtIndex:1]

If you sure that you're having two windows , then you can check that with using method isKindofClass , Like,

if([secondWindowisThere isKindofClass:[UIAlertview Class]]) {
// your code here
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM