Check if a UIAlertView is showing

后端 未结 10 1365
刺人心
刺人心 2020-11-27 16:45

I have a method that posts HTTP data and displays a UIAlertView if there is an error. If I have multiple HTTP post I will show multiple UIAlertView for every error.

10条回答
  •  再見小時候
    2020-11-27 17:42

    Why not just check the visible property, maintained by the UIAlertView class?

    if (_alert) //alert is a retained property
    {
        self.alert = [[[UIAlertView alloc] initWithTitle:@"Your Title"
                                                 message:@"Your message" 
                                                delegate:self
                                       cancelButtonTitle:@"Cancel"
                                       otherButtonTitles:@"OK"] autorelease];
    }
    if (!_alert.visible)
    {
        [_alert show];
    }
    

提交回复
热议问题