views:

85

answers:

2

hi all

i googled for hours now but i can't find a code example, which describes how to show an uiactivityview while an operation/method is loading.

in my case i want to show it while i load a large image to an uiimageview. have you got an idea how to realize that?

thanks in advance.
sean

A: 

well its quit easy.

  1. show activity indicator
  2. start thread loading that image
  3. if image loaded, thread tells mainapp to kill activity indicator.

   NSThread detachNewThreadSelector:@selector(myMethod) 

toTarget:self withObject:nil];

and

      [self performSelectorOnMainThread:@selector(myMethod) 
           withObject:nil 
           waitUntilDone:false];

will be helpfully. taken from http://www.iphoneexamples.com/

dhanke
A: 

You might want to look in the UI UIActivityIndicatorView Class Reference documentation.

Make sure to return to the run loop while waiting for the image to load in order to see the activity indicator animating. Also, you will probably need to create a method to stop the activity indicator, and perhaps call that stop method by doing a performSelectorOnMainThread from whatever method handles the asynchronous completion of the loading.

hotpaw2