views:

61

answers:

3

I have a delegate method with the following tasks:

  • get something from the internet (ex: some image from a web site);
  • process that image in a certain way;
  • display the result in a subview ;

getting the image takes some time, depending on the network's speed so the result of its processing is displayed in the subview after that little while.

my problem: during the time between getting the image and showing the result the device looks unresponsive. any attempt to put some spinner, or any other method which is called inside this main procedure has no effect until the result is processed. how should I change this behaviour? I would like to put a big spinner during that waiting time.

thank you.

+3  A: 

See iphone-dev-tips for a very basic approach on asynchronous fetching of a UIImage.

stigi
A: 

You want to spawn a new thread to perform the lengthy task. Take a look at this Apple Guide:

http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/Multithreading/CreatingThreads/CreatingThreads.html

pheelicks
You don't want to create a new thread for such a trivial task. Asynchronous NSURLConnection ist the way to go.
stigi
A: 

I found the LazyTableImages to be very instructive on how to best implement this behavior. In my opinion, the spinner is to be avoided at all costs.

We also make use of NSOperationQueue to handle background loading of upwards of 500 images without slowing the UI down much.

Cheers, -dan

Daniel Blezek