Question

My app use a custom navigation controller.

When I push UIVIewController up on the navigation stack I have to load data over the network.

I use :

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void) {

});

to load my data so the app is still responsive and so the user can press the back button which uses :

[self.navigationController popViewControllerAnimated:YES] 

When data has been loaded I often refresh UIElements like UITableView, UILabel... when we press the pushBack button the controller is no more the current controller so when the elements are refreshed everything crashes.

So I have two questions :

  • How can i know if the controller where the refresh is set is the current controller or not ?
  • I think i have miss something, does Apple did not know it would happen and they have a probably set something for it ?

Thank you for any help, sorry for my English.

Was it helpful?

Solution

Show a activity indicator while you are loading the data . Till the time data is getting loading do not allow the user to pop the current view controller . this could be implemented by adding a transparent view to the current on the top and remove the transparent view soon after the loading is completed . This functionality could easily be implemented using MBProgressHUD .

Here is the Link : https://github.com/jdg/MBProgressHUD

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top