开发者

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

开发者 https://www.devze.com 2022-12-25 20:20 出处:网络
开发者_如何转开发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 dat

开发者_如何转开发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?


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];


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

0

精彩评论

暂无评论...
验证码 换一张
取 消