I would like to use a spinner. But, this code below does not display a spinner and I'm not sure why. How to make this work? BTW, It is being called from a submit button I created.
//spinner declared in .h file
UIActivityIndicatorView *aSpinner;
//throw up spinner from submit btn we created
aSpinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:
UIActivityIndicatorViewStyleWhiteLarge];
[self.view addSubview:aSpinner];
[aSpinner release];
[aSpinner startAnimating];
//send blocking request
[request startSynchronous];
//get rid of spinner when finished delegate is fired
- (void)requestFinished:(ASIHTTPRequest *)request
{
NSLog(@"REQUEST FINISHED");
[aSpinner stopAnimating];
//[aSpinner release];
}
If you call some blocking code immediately after you display the spinner, the UI won’t get updated, since it only updates when the main run loop is running. If this really is the source of the problem, the spinner should show up when you comment out the [request startSynchronous]
line for a test.
The solution would be to use an asynchronous request. The delegating code looks like you already do that, but on the other hand the start call mentions synchronous operation. Care to explain? (Or did I overlook something?)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With