1

我有一个带有 TableView 和一个 MapView 的 ViewController 以及一个打开带有另一个 TableView 的 PopOver 的按钮。在那里,用户可以选择一些应该显示在 Table 和母 ViewController 中的 MapView 上的位置。

我有一个计算表格数据并在母 ViewCoontroller 中绘制这些注释的函数。这是通过初始化从子 ViewController 调用的:

MotherViewController * MVC = [[MotherViewController alloc] init];
[MVC calculateresults];

然后通过协议将选定的数据传回,函数计算正确的结果。但是表格不会重新加载,因为 [self.TableView reloaddata] 在 PopOver 仍然打开时不起作用。如果我关闭 PopOver 并直接在母 ViewController 上启动该功能,一切正常。

已经尝试过了,但不起作用: iPad SplitViewController: Reloading root view controller's tableview from detail view controller

如何在打开 PopOver 时更新母 ViewController 中的地图和表格?

4

1 回答 1

0

失败的原因不是“[self.TableView reloaddata] 在 PopOver 仍然打开时不起作用。” 原因是self不同的self。你是说:

MotherViewController * MVC = [[MotherViewController alloc] init];
[MVC calculateresults];

在弹出框后面看到的MVC不是MotherViewController。它是一个不同的MotherViewController - 你刚刚创建的那个alloc。因此,您在弹出框后面看到的 MotherViewController 永远不会收到任何消息,因此它什么也不做。

自然,当您直接在MotherViewController 中执行此操作时,它会起作用。

而不是说

MotherViewController * MVC = [[MotherViewController alloc] init];

您需要安排您的弹出框引用已经存在的MotherViewController。

于 2013-04-02T22:53:34.943 回答