Grouped UITableView shows blank space when section is empty

后端 未结 11 590
别跟我提以往
别跟我提以往 2020-12-30 23:44

I have a grouped UITableView where not all sections may be displayed at once, the table is driven by some data that not every record may have. My trouble is that the record

11条回答
  •  醉话见心
    2020-12-31 00:17

    I solved the issue by setting tableView's dataSource and delegate where I initialize the tableView.

    Note: remember you might need to make tableView lazy to assign when initializing the tableView.

    lazy var tableView: UITableView = {
            let tableView = UITableView(frame: .zero, style: .grouped)
            tableView.separatorStyle = .none
            tableView.backgroundColor = .white
            tableView.dataSource = self
            tableView.delegate = self
            return tableView
        }()
    

提交回复
热议问题