iphone - Update text in alert message -


still trying update message in uialertview while alert active. removed of first part of question , publish more code in update below.

update 3: adding more code! in .h file declare following (among others):

@interface webviewcontroller : uiviewcontroller <uiwebviewdelegate> {  iboutlet uiwebview *webview; uialertview *alert;  } 

i @property , @synthesize uialertview to.

next create alert in ibaction run button click:

-(ibaction)convert {  convertbutton.enabled = no; mailbutton.enabled = no; backbutton.enabled = no;  //show alert window alert = [[uialertview alloc] initwithtitle:@"converting in progress\nplease wait..." message:@"\n\n\n" delegate:self cancelbuttontitle:nil otherbuttontitles: nil]; [alert show];  uiactivityindicatorview *indicator = [[uiactivityindicatorview alloc] initwithactivityindicatorstyle:uiactivityindicatorviewstylewhitelarge];  // adjust indicator few pixels bottom of alert indicator.center = cgpointmake(alert.bounds.size.width / 2, alert.bounds.size.height - 50); [indicator startanimating]; [alert addsubview:indicator];  [indicator release];  [alert setmessage:@"getting roster"]; } 

it jumps following function:

- (void)didpresentalertview:(uialertview *)progressalert {     //a lot of code       [alert setmessage:@"checking history"];    //more code       [alert setmessage:@"writing history"];    //even more code       [alert setmessage:@"converting roster"]; } 

the didpresentalertview method ends asihttprequest post data webpage , when request finished code jumps last method exit uialertview , closes up:

- (void)requestfinished:(asihttprequest *)request {     [timer invalidate];    [alert dismisswithclickedbuttonindex:0 animated:yes];    backbutton.enabled = yes;    [alert release]; } 

i removed autorelease uialertview init make sure exists during rest of process.

as now, code fires first setmessage -> 'getting roster' , last -> 'converting roster'. setmessage requests in middle not fired..

really hope can me here!

thanks all!

now see problem.

when update message property, doesn't fire redrawing view right away. view marked 'needed drawn', , actual drawing happens later, typically @ end of current or next runloop in main thread.

therefore, while didpresentalertview method running on main thread, alert view not redrawn until method finished. why computation-intensive job needs run on separate thread increase responsiveness of ui, ui-related job done on main thread.

what should run //a lot of code //more code , //even more code on separate thread, , update message property on main thread.

for example, code may similar :

    // inside didpresentalertview method     nsoperationqueue* aqueue = [[nsoperationqueue alloc] init];     [aqueue addoperationwithblock: ^{         // lot of code         [alert performselector:@selector(setmessage:) onthread:[nsthread mainthread]                        withobject:@"checking history" waituntildone:no];         // more code         [alert performselector:@selector(setmessage:) onthread:[nsthread mainthread]                        withobject:@"writing history" waituntildone:no];         // goes on     }]; 

if working ios 4.0 , later, , want use gdc, careful because may detect independency of computation , message updates , let them happen concurrently (which not desired here).


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -