UItableview внутри ячейки Uitableview, внутренний uitableview не отображается - PullRequest
0 голосов
/ 05 сентября 2018

Я пытаюсь добавить UItableview в ячейку Uitableview, но внутренний uitableview не отображается. Внешний табличный вид имеет тег 100 и внутренний тег 90. Я не уверен, почему отображается только внешнее табличное представление, а код никогда не достигает тега 90. Не могли бы вы посоветовать? Я застрял с этим в течение нескольких дней. Пожалуйста, найдите код ниже. Спасибо!

import UIKit

class ViewController: UIViewController ,UITableViewDataSource,UITableViewDelegate{
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        if tableView.tag == 100 {
            return 10
        } else {
            return 3
        }
    }

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        if tableView.tag == 100 {
            let cell = tableView.dequeueReusableCell(withIdentifier: "MainTableViewCell") as! MainTableViewCell
            return cell
        } else {
            let cell = tableView.dequeueReusableCell(withIdentifier: "InsideTableViewCell") as! InsideTableViewCell
            return cell
        }
    }
}

import UIKit

class MainTableViewCell: UITableViewCell {
    @IBOutlet var lblName: UILabel!
    @IBOutlet var tblInsideTableView: UITableView!

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
}

extension MainTableViewCell {
    func setTableViewDataSourceDelegate
        <D:UITableViewDelegate & UITableViewDataSource>
        (_ dataSourceDelegate: D, forRow row: Int)
    {
        tblInsideTableView.delegate = dataSourceDelegate
        tblInsideTableView.dataSource = dataSourceDelegate

        tblInsideTableView.reloadData()
    }
}


import UIKit

class InsideTableViewCell: UITableViewCell {
    @IBOutlet var lblInsideName: UILabel!

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...