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

时间:2015-01-26 16:10:00

标签: ios objective-c nsurlconnection uialertview uiactivityindicatorview

我有UIAlertView UIActivityIndicatorView

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];

如何从以下方法中解除此警报:我可以使用警告标记解除吗?我的警报视图中没有包含任何按钮。

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

1 个答案:

答案 0 :(得分:1)

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