UIActivityIndi​​cator

时间:2012-07-15 15:38:59

标签: iphone xcode uiactivityindicatorview

当我使用StartAnimating方法启动UIActivityIndi​​catorView时: [ActivityIcon startAnimating];

它会禁用所有用户交互,因此当用户点击取消按钮时应该中止下载过程并隐藏UIActivityIndi​​cator它不起作用!!!

任何建议都将受到赞赏。

编辑: 我使用单独的线程在后台下载文件。我完成了所有进度报告和用户界面互动:

[self performSelectorOnMainThread:@selector(RefreshScreen :) withObject:nil waitUntilDone:YES];

和RefreshScreen方法是与UI元素交互的方法。

1 个答案:

答案 0 :(得分:3)

尝试更改此行:[request startSynchronous];至:[request startAsynchronous];

修改

- (IBAction)grabURLInBackground:(id)sender
{
   NSURL *url = [NSURL URLWithString:@"http://allseeing-i.com"];
   ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
   [request setDelegate:self];
   [request startAsynchronous];
}

- (void)requestFinished:(ASIHTTPRequest *)request
{
   // Use when fetching text data
   NSString *responseString = [request responseString];

   // Use when fetching binary data
   NSData *responseData = [request responseData];
}

- (void)requestFailed:(ASIHTTPRequest *)request
{
   NSError *error = [request error];
}