iphone - Network activity indicator problem -
i have application has toolbar uisegmentedcontrol nested inside of subview. when switch segment done follows:
/* * set/reset dei dati. */ [[uiapplication sharedapplication] setnetworkactivityindicatorvisible:yes]; if ( bannervideo ) { [filmatibanner release]; filmatibanner = nil; filmatibanner = [[nsmutablearray alloc] initwithcapacity:0]; [[bannervideo view] sethidden:yes]; [bannervideo release]; bannervideo = nil; } [lowerbanneractivity sethidden:no]; [lowerbanneractivity startanimating]; url = [nsurl urlwithstring:@"http://www.udc.ntx.it/filmatiblocco2.asp"]; request = [asiformdatarequest requestwithurl:url]; [request setpostvalue:[[voci objectatindex:[switches selectedsegmentindex]] objectforkey:@"codblocco"] forkey:@"codiceblocco"]; [request startsynchronous]; // bla bla yada yada
when view loads correctly see uiactivityindicator spinning , networkactivity in status bar above. when tap switch, app "freezes" until done job fastly shows spinner , hides it. how should rid of problem?
you should loading activity in thread - doing in same (main) thread: startsynchronous indicates this. think asi library supports loading in different thread, i'm not familiar library. (you can call
[request setdelegate:self];
[request startasynchronous];
and implement:
-(void)requestfinished:(asihttprequest *)request
and in method remove network activity indicator. )
or can (the hard way - start own thread ;)) :
[nsthread detachnewthreadselector:@selector(loadbanner:) totarget:self withobject:param];
when loadbanner method over, should return main thread banner loaded, this:
(calling loadbanner method)
[self performselectoronmainthread:@selector(bannerisloaded:) withobject:rez waituntildone:no];
and in method bannerisloaded remove network activity indicator , show banner itself.
Comments
Post a Comment