弹出 UIViewController 时未调用 UITableView 委托
我有一个包含 UITableView 的视图控制器。当视图控制器被推入堆栈时,表视图委托方法被调用并填充表。
然后我将另一个视图控制器推到包含表视图的视图控制器上。我想要发生的是 - 当第二个视图控制器被弹出并且我返回到前一个视图控制器时,那些 uitableview 委托方法会再次被调用(以便重新填充表)。
换句话说,当弹出到视图控制器时如何重新填充 uitableview。
谢谢
I have a view controller that contains a UITableView. When the view controller gets pushed onto the stack, the table view delegate methods get called and it populates the table.
Then I push another view controller onto the one that contains the table view. What I would like to make happen is that - when the second view controller gets popped and I return to the previous view controller, those uitableview delegate methods get called again (so as to repopulate the table).
In other words, how do you repopulate a uitableview when popping to a view controller.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在
viewDidLoad
或viewDidUnload
、viewWillAppear
、viewWillDisappear
(无论其中哪个适合您的情况)中,您可以输入 <代码> [myTable reloadData]; :In
viewDidLoad
orviewDidUnload
,viewWillAppear
,viewWillDisappear
(whichever of these is right for your situation) you can put[myTable reloadData];
:您应该做的是在其视图控制器的 viewWillAppear 方法内添加一个
[self.tableView reloadData]
(或任何表变量)调用。这将导致表视图在被推送时(就像现在一样)和弹出其他视图控制器以显示它时重新加载。What you should do is add a
[self.tableView reloadData]
(or whatever your table variable is) call inside theviewWillAppear
method of its view controller. This will cause the table view to be reloaded both when being pushed (as it does now) and when other view controllers are popped to reveal it.