且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

iPhone SDK:检查是否显示UIAlertView

更新时间:2023-11-29 10:39:10

在调用的对象上调用ivar之前调用show方法UIAlertView。

On the object that calls set an ivar before invoking the show method on your UIAlertView.

...

if (!self.alertShowing) {
    theAlert = [[UIAlertView alloc] initWithTitle:title message:details delegate:self cancelButtonTitle:nil otherButtonTitles:@"Okay", nil];
    self.alertShowing = YES;
    [theAlert show];
}

...

然后在你的委托方法中对于警报管理将您的标志ivar设置为否:

Then in your delegate method for the alert manage setting your flag ivar to no:

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
  ...
      self.alertShowing = NO;
}

如果您希望按顺序显示警报,我会发布通知以添加每个警报消息发送到队列,然后仅在解除警报后从队列中取消消息。

If you want the alerts to show sequentially, I would post notifications to add each message to a queue and then only take a message off the queue after an alert is dismissed.