Reload UITableView when navigating back?

前端 未结 7 1693
醉梦人生
醉梦人生 2021-01-30 06:38

I have a top level UIViewController that contains a UITableView. The top level UIViewController instantiates a NavigationController

7条回答
  •  悲哀的现实
    2021-01-30 07:10

    You could implement the methods of UINavigationControllerDelegate and create the logic for the refreshing when popping view controllers.

    Another way to do this would be implementing on your table view controller some logic on viewWillAppear, to refresh based on the data of the popped view controller.

    If you need to send data from the second view controller to the first view controller, remember that your second view controller "doesn't" know the existence of the previous view controller. It should be transparent for it. You should implement some protocol to make the second view controller send data to the first view controller. It would be a third option to this problem, since your first view controller would be the delegate and the second view controller would be sending info to the delegate, you could be preparing your table view (first view controller) to reload, based on the received data.

提交回复
热议问题