问题
I working on an app with tabs which shows info about a person in a database. In one of my tabs there is a textbox through which a user can search for a new person.
My problem is, how do I refresh all my tabs with the information from the new person?
I make a server call and get all the new info but I just don't know how to refresh the entire app. Any help would be appreciated.
Thank you
回答1:
Post a notification when old data is invalidated and post a notification when new data is available. Make your view controllers listen for these notifications. When old data is invalidated, show a loading notification. When new data is available, update your views and clear any loading notification.
回答2:
(void)applicationDidBecomeActive:(UIApplication *)application { \\\your code }
Reload the data in the above function of the app delegate to refresh the data when ever the app comes to foreground. You can call this function on a button click!
来源:https://stackoverflow.com/questions/12239260/refresh-the-entire-ios-app