2

I want to check whether the UIALertView is present on the screen or not, though I have done it by using the following method:

-(BOOL) isAlertShowing
{

    for (UIWindow* window in [UIApplication sharedApplication].windows) {
        NSArray* subviews = window.subviews;
        if ([subviews count] > 0)
            if ([[subviews objectAtIndex:0] isKindOfClass:[UIAlertView class]])
                return YES;
    }
    return NO;      
}

but I came to know that it is undocumented one. So, please tell me authenticate way of doing it.

Vladimir
  • 170,431
  • 36
  • 387
  • 313
anshul
  • 846
  • 1
  • 14
  • 32
  • do one thing when you present the alert view by [alert show] method so after dat maintain a BOOL variable YES. – Arun Dec 19 '11 at 13:30
  • 2
    I don't see any private API in your method. It won't win a beauty contest, but it ain't wrong either. – Johan Kool Dec 19 '11 at 13:35
  • Actually, I want the alert to be shown when its not done by my device, itself. For example, in case of location services, if device doesn't show alert, then I want to show my custom alert. – anshul Dec 19 '11 at 13:36
  • Out of curiosity, why would you even need this? Don't you know when you've presented an alert and when it's been dismissed by hitting one of the buttons? – Brad Larson Dec 20 '11 at 18:32
  • hey Brad, as the system is responsible for alerting the user (in case of GPS alert), we don't know how to catch the button method – anshul Dec 21 '11 at 06:07

1 Answers1

0

In an app I submitted (and is approved), I have used a similar approach (see iPhone: detecting if a UIAlert/UIActionSheet are open)...

I don't see why you think it's not a valid method - I'd try it.

Community
  • 1
  • 1
Reuven
  • 2,142
  • 3
  • 18
  • 30