弹出 UIViewController 时未调用 UITableView 委托

发布于 2024-12-08 19:44:20 字数 224 浏览 0 评论 0原文

我有一个包含 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

记忆消瘦 2024-12-15 19:44:20

viewDidLoadviewDidUnloadviewWillAppearviewWillDisappear(无论其中哪个适合您的情况)中,您可以输入 <代码> [myTable reloadData]; :

// If you can include some code it would help as I am a bit uncertain
// about exactly what you are trying to do from the question but
// you should use whichever of these is correct for project:

- (void)viewDidLoad {
    [super viewDidLoad];
    [myTable reloadData];
}

- (void)viewDidUnload {
    [myTable reloadData];
}

- (void)viewWillAppear {
    [super viewWillAppear];
    [myTable reloadData];
}

- (void)viewWillDisappear {
    [super viewWillDisappear];
    [myTable reloadData];
}

In viewDidLoad or viewDidUnload, viewWillAppear, viewWillDisappear (whichever of these is right for your situation) you can put [myTable reloadData];:

// If you can include some code it would help as I am a bit uncertain
// about exactly what you are trying to do from the question but
// you should use whichever of these is correct for project:

- (void)viewDidLoad {
    [super viewDidLoad];
    [myTable reloadData];
}

- (void)viewDidUnload {
    [myTable reloadData];
}

- (void)viewWillAppear {
    [super viewWillAppear];
    [myTable reloadData];
}

- (void)viewWillDisappear {
    [super viewWillDisappear];
    [myTable reloadData];
}
靖瑶 2024-12-15 19:44:20

您应该做的是在其视图控制器的 viewWillAppear 方法内添加一个 [self.tableView reloadData] (或任何表变量)调用。这将导致表视图在被推送时(就像现在一样)和弹出其他视图控制器以显示它时重新加载。

What you should do is add a [self.tableView reloadData] (or whatever your table variable is) call inside the viewWillAppear 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文