I need to refresh the content of a view as soon as I popViewController

最后都变了- 提交于 2020-01-14 22:44:51

问题


ViewA load some data from Coredata, then push to the next viewB. In viewB, there are some function, that will change the content of viewA (meaning viewB change the content of core data). However, when I pop the view back to viewA, my content stay the same as before. How can I fix this?


回答1:


in viewA's -(void)viewWillAppear:(BOOL)animated delegate method you can refresh the control you need... i.e. if you want to reload table that in viewWillAppear method write

[Table reloadData];



回答2:


There are two ways to do this:

The content of viewA that u would be setting in viewDidLoad method of the viewCOntroller of viewA can be set in viewWillAppear. In this way the contents of the view will be reloaded always when a view is appeared.

The other way is little tough but much more efficient in terms of performance. Have a boolean variable in viewA, now its value should be set to true when u change any thing in viewB by having its reference in viewB, now when you pop check in viewWillAppear if the boolean is changed to true. if yes set it to no again and call the method that you called from view did load to load the data in the viewA.

Hope this helps.

Thanks,

Madhup



来源:https://stackoverflow.com/questions/2597421/i-need-to-refresh-the-content-of-a-view-as-soon-as-i-popviewcontroller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!