我有一个带有标签和文本字段的 View Controller 。我还添加了一个容器 View ,它指向另一个具有一个部分和 3 行的 TableView Controller ,基本上是静态 TableView 。我找不到任何文档/示例来告诉您如何在包含容器 View 的 View Controller 和嵌入在容器 View 中的 TableView 容器之间传递数据。我想要双方沟通?
最佳答案
嵌入在容器 View ( Storyboard)中的 Controller 会自动添加为添加了容器 View 的 Controller 的 childViewController。只是为了理解我的意思,在基本 Controller 的 viewDidLoad 方法中添加这一行:
NSLog(@"children : %@", self.childViewControllers);
假设在 VC1 中,您添加了一个带有嵌入式 Controller VC2(您的 tableViewController)的容器 View ,然后上述语句会将 VC2 记录为 VC1 的子级。要从 VC1 访问 VC2,只需使用 [self.childViewControllers objectAtIndex:0],要从 VC2 访问 VC1,只需使用 self.parentViewController。
希望对你有帮助
关于ios - 在 ios 6 中,如何在持有 'Container View' 对象的 View Controller 和嵌入其中的 TableView Controller 之间使用传递数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14657527/