简体   繁体   English

在主视图控制器中的子容器视图中获取tableView的引用

[英]Getting reference of a tableView in a child container view in the master view controller

I have a UIViewController that has a comment UITextView in the bottom. 我有一个UIViewController在底部有一个注释UITextView And on the top part of the view controller i have a UIView "A content view" that has a comments UITableView being served in it. 在视图控制器的顶部,我有一个UIView “ A content view”,其中包含了评论UITableView

What i need is a reference for the tableView found in the content UIView in the master UIViewController so i would be able to reload the tableView after posting a comment. 我需要的是在主UIViewController的内容UIView中找到的tableView的引用,因此我可以在发布评论后重新加载tableView。

Tried several things with no luck. 尝试了几件事,没有运气。 Always nil . 总是nil Can anybody help me with a sample. 有人可以帮我提供样品吗?

在此处输入图片说明

class MyViewController: UIViewController {

    let tableView = UITableView(frame: .zero, style: .grouped) // for example

}

Now your table view is accessible from anywhere in the view controller. 现在,您可以从视图控制器中的任何位置访问表视图。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM