show uiactivityview while an other operation is loading
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.
seanYou 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.
well its quit easy.
- show activity indicator
- start thread loading that image
- 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/
精彩评论