如何在成功连接 NSURL 后关闭警报视图

How to dismiss alert view after a successful NSURL connection

我有一个 UIAlertViewUIActivityIndicatorView

UIAlertView *alertView_Spinning = 
   [[UIAlertView alloc] initWithTitle:@"Please wait" 
                              message:@"Connecting to server" 
                             delegate:nil 
                    cancelButtonTitle:nil 
                    otherButtonTitles: nil];
alertView_Spinning.tag=0;

UIActivityIndicatorView *indicator = 
  [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
[indicator startAnimating];

[alertView_Spinning setValue:indicator forKey:@"accessoryView"];
[alertView_Spinning show];

如何从下面关闭此警报 method:Can 我使用警报标签来关闭?。我的提醒视图中没有包含任何按钮。

- (void)connectionDidFinishLoading:(NSURLConnection *)connection{
    //dismiss alert view here
}

您应该将其分配给当前 class 的 ivar 或 属性 而不是作为局部变量,然后在 connectionDidFinishLoading: 处理程序中调用 dismissWithClickedButtonIndex:animated: