【问题标题】:How to add data to a TableView present inside a TableViewCell [duplicate]如何将数据添加到 TableViewCell 中存在的 TableView [重复]
【发布时间】:2017-10-02 13:50:20
【问题描述】:

我有一个 tableViewCell,里面有一个 TableView,而 TableView 又有一个 tableViewCell。如何访问最里面的 tableView 和 tableViewCell 以向其中添加数据?我正在尝试做一些类似 facebook 评论页面的事情。

任何帮助将不胜感激。 谢谢。

【问题讨论】:

标签: ios swift uitableview tableview tableviewcell


【解决方案1】:

你可以这样做:

class mainTableViewController: UITableViewController {
    //your functions here
}

//你的自定义单元格类

class yourCustomCell:UITableViewCell,UITableViewDataSource,UITableViewDelegate{
    @IBOutlet weak var innerTableView : UITableView?
    var myArray : Array<Any> = []
    override func awakeFromNib() {
        super.awakeFromNib()
        innerTableView?.dataSource = self
        innerTableView?.delegate = self
    }

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return myArray.count
    }
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = UITableViewCell.init(style: .default, reuseIdentifier: "identifier")
        return cell
    }
}

【讨论】:

  • 能否解释一下如何将数据从 maintableViewController 传递到 yourCustomCell 以显示数据
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-12-17
相关资源
最近更新 更多