iphone - Why is there a delay when presenting this modal view? -


i have app starts tableview (from xib) loads multiple navigation controllers. want present modal view on startup if long init sequence underway. tried presenting modal view in app delegate, view doesn't appear until after underlying code complete.

mainwindow.xib loads tableviewcontroller, put call presentmodalview in view appear same result. have numerous nslog calls can watch happening can't figure out why view doesn't appear until after both app delegate , tableview controller's viewwillappear finish. moved call viewdidappear same result. here code snippet:

app delegate:

- (void)applicationdidfinishlaunching:(uiapplication *)application {      // add tab bar controller's current view subview of window     [window addsubview:tabbarcontroller.view];     [window makekeyandvisible];     [[uiapplication sharedapplication] setstatusbarhidden:no];      // if new version being installed init stuff     if ( <needs update code here>) {         uncompress *uncompressview = [[uncompress alloc] initwithnibname:@"uncompress" bundle:nil];         [self.tabbarcontroller presentmodalviewcontroller:uncompressview animated:no];         [uncompressview release];     } } 

i tried changing presentmodalviewcontroller [window addsubview:uncompressview.view] without luck.

the update code runs fine, problem view doesn't appear until both appdelegate , tableview finished. i'm not creating views programatically - xib's. can't figure out call update function view appear right away. appreciated. thank you!

on ios, ui updated when code returns control run loop. if uncompress task takes lot of time, ui updated after has finished.

you can sort of work around issue putting time-intensive task in separate method , calling method [self performselector:... afterdelay:0.0 ...]; not solution because if ui update, user interaction app still blocked long code blocks main thread. , if code takes more few seconds run (e.g. because runs on older, slower device), os watchdog timer kill app.

the best solution put time-intensive task in background thread, e.g. nsoperation or dispatch_async().


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -