ios - Unexpected delay after pushing view controller -
i have tab bar controller, inside 1 of tabs have 3 container view controllers. 1 can presented, others removed @ moment. views controllers defined in xib.
in 1 of containers have table view.
when click on cell have push view controller.
first time launch app have delay when pushing view controller. after go table view , push again, there no delay.
i print time when in didselectrowatindexpath
, in viewdidload
of new controller, , delay between 2 , 4 seconds.
this code use pushing view controller:
eventdetailsviewcontroller *eventdetailsvc = [[eventdetailsviewcontroller alloc]init]; events *event = [self.events objectatindex:indexpath.row]; eventdetailsvc.curentevent = event; nsdateformatter *f2 = [[nsdateformatter alloc] init]; [f2 setdateformat:@"dd mmmm, hh:mm:ss.sss a"]; nslog([f2 stringfromdate:[nsdate date]]); dispatch_async(dispatch_get_main_queue(), ^{ [self.navigationcontroller pushviewcontroller:eventdetailsvc animated:yes]; });
usually don't use dispatch_async
when pushing view controller, 1 of suggested solutions i've found. tried self.parentviewcontroller.navigationcontroller
, same results.
i don't know delay, me.
thanks.
most child view controller problem here. make sure viewdidload / loadview don't start expensive operations (like downloading data internet).
viewdidload & loadview fire once, when view controller shown first time. once view property set, these methods won't fire anymore.
any loading of content should done on background thread (perhaps using library afnetworking) , should (usually) either start in viewwillappear or viewdidappear.
Comments
Post a Comment