2017-05-04 46 views
0

我有一個tableViewCell,其中我有一個TableView,它又有一個tableViewCell。如何訪問最內層的tableView和tableViewCell以向其添加數據?我正在嘗試做一些類似Facebook的評論頁面。如何將數據添加到TableViewCell內部的TableView中

任何幫助將不勝感激。 謝謝。

+0

我相信這個問題的回答將幫助你http://stackoverflow.com/questions/17398058/ is-it-it-it-add-uitableview-within-a-uitableviewcell –

回答

0

你可以這樣做:

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 
    } 
} 
+0

可以請我解釋一下,如何將數據從maintableViewController傳遞到yourCustomCell以顯示數據 –

相關問題