问题
I have a table view, which populates data from the web. To add information to this list I have a configuration screen presented modally. When data is added successfully the configuration screen is dismissed, I would like the data in the table view to automatically reload from the web to reflect the newly added data.
What is the best way to go about reloading this remote data after the configuration view is dismissed. I have tried a number of approaches including using a delegate to send information back and loading the data only on view will appear but would like to know the safest and most efficient way of doing this.
Thanks in advance!
回答1:
You want to load it on view loading, it greatly simplifies things—Plus, it only loads data when your user wants it, thus saving him or her potentially some data on their conceivably limited data plan if on 3g.
While the data is loading, if the view has appeared, then you can display a "loading" view on top of your view, disable user interaction until it's done loading, then remove it from its superview and enable user interaction again, while presenting the data to your table view. This is generally how I've done it in the past, and how I'd look at doing it in the future.
来源:https://stackoverflow.com/questions/3383302/reload-data-on-view-controller-dismiss