iphone - iOS4 networkActivityIndicatorVisible blocked through UI -


i doing request download images want replace subview them. means ui blocked , new view displays sometime later.

i want user understand blocking occurs due download.

first tried use

[uiapplication sharedapplication].networkactivityindicatorvisible = yes; [self downloadfunction]; [uiapplication sharedapplication].networkactivityindicatorvisible = no; 

that leads maxium blink (mostly nothing) of activity indicator, since request blocking ui thread.

i cannot put downloadfunction background, since depend on downloaded data available before push controller (would lead error "pushing same view controller instance more once not supported" since click button more once).

then tried put subview spinning wheel on top of view:

[self performselectorinbackground:@selector(showactivitysubview) withobject:nil]; or   [nsthread detachnewthreadselector: @selector(showactivitysubview) totarget:self withobject:nil]; 

but still ui blocked , indicator displayed after download finished...

any ideas?

you can split method in 2 , use timed call allow ui refresh thread pick before block main thread. example:

- (void) doactualwork {   [self downloadfunction];   [uiapplication sharedapplication].networkactivityindicatorvisible = no; }  - (void) dowork {   [uiapplication sharedapplication].networkactivityindicatorvisible = yes;   [self performselector:@selector(doactualwork) withobject:nil afterdelay:0.05]; } 

there's better way of doing this, , i'm not sure little indicator on task bar enough activity indication keep app review folks happy, should work , won't require threading.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -