2

When I start UIActivityIndicatorView using StartAnimating method: [ActivityIcon startAnimating];

it disable all user interactions so when the user Tap on Cancel button which should abort the download process and hide the UIActivityIndicator it does not work!!!

any suggestions would be appreciated.

Edit: I am using separate thread to download the files in the background. All progress reporting and UI interaction I made it through:

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

and RefreshScreen method is the one who interact with the UI elements.

4
  • 2
    You need to make your download asynchronous. Can you provide your code, please? Commented Jul 15, 2012 at 15:41
  • It takes a lot of time to download a single file. and the user maybe frustrated while he do not know how much of the download has been accomplished. to download a file I use these lines ASIHTTPRequest* request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:[oElement objectForKey:@"URL"]]]; [request setDownloadProgressDelegate:self]; [request setShouldContinueWhenAppEntersBackground:YES]; [request setDownloadDestinationPath:strDownloadPath]; request.delegate = self; [request startSynchronous]; Commented Jul 15, 2012 at 15:47
  • 1
    try change this line: [request startSynchronous]; to: [request startAsynchronous]; Commented Jul 15, 2012 at 15:50
  • Please edit your post to add additional code, and use the brackets to format it well. You see the line [request startSynchronous] that's why everything is blocked: It's a synchronous request, this means everything is blocked and is working step-by-step. What you need is to do a ASYNCHRONOUS request, this means nothing is blocked and you can provide additional information about the progress, etc. Commented Jul 15, 2012 at 15:50

1 Answer 1

3

try change this line: [request startSynchronous]; to: [request startAsynchronous];

EDIT

- (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];
}
Sign up to request clarification or add additional context in comments.

4 Comments

It's a shame to copy an answer from another user: stackoverflow.com/questions/5176461/…
i know right, it is a shame to copy the documentation code allseeing-i.com/ASIHTTPRequest/… do you agree?
It's a shame of me - I'm sorry. I never used ASIHTTPRequest and saw the other answer a minute ago.
Sorry guess I thought Synchronous is none blocking and Asynchronous is blocking. but seems it is reversed.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.