is there a way to display the animated spinning wheel while the main thread does a lengthy operation? The animation is handled by the same thread that created the UIActivityIndicatorView, right? If so, can views that belong to several threads sit in the same view hierarchy?
All else failing, I don't mind moving a lengthy operation itself into a background thread, but then I'd have to freeze the UI somehow while it's running. That I'm not sure how to do.
EDIT: "lengthy" is around 2 sec on a 1st-gen device.
The solution is to start the animation at least one iteration through the run loop before running the lengthy operation. For example:
[activity startAnimating];
[self performSelector:@selector(lengthyOperation) withObject:nil afterDelay:0];
You don't have to use the performSelector
method, just some way to set the method to run later so the activity indicator has a chance to start animating before you get busy.