ios - Swift UITableViewController Reduce Loading Time -
i'm creating ios app in swift 1.2 master-detail uitableviewcontroller setup mastertableviewcontroller has cells push detailtableviewcontroller.
detailtableviewcontroller has complex cells pull data web client generate chart, similar in apple's health app. takes 5-10 seconds data download.
as result, there 5-10 second delay when cell in mastertableviewcontroller tapped before detailtableviewcontroller shown.
i ideally push mastertableviewcontroller detailtableviewcontroller , display activity indicator on detailtableviewcontroller page dismissed when data downloaded.
could point me in direction accomplish this? thank you! :)
my code below pushing master detail. basic. feel if change in viewdidload or cellforrowatindexpath method, done easily.
func tableview(tableview: uitableview, didselectrowatindexpath indexpath: nsindexpath) { tableview.deselectrowatindexpath(indexpath, animated: false) let detailvc = detailtableviewcontroller() detailvc.navigationitem.title = "your charts" self.navigationcontroller?.pushviewcontroller(detailvc, animated: true) }
on detail view controller can create uiactivityindicatorview variable.
in viewdidappear can call activity indicator, bring front , start animating it.
the create function populates array store data cells use , re work cellforrowatindexpath use it. (instead of fetching data in each cell).
then in function fetch data, right after (or before) update table tell activity indicator stop animating.
Comments
Post a Comment