gpt4 book ai didi

ios - tableView(_ tableView : UITableView, cellForRowAt indexPath: IndexPath) 没有在 UITableViewController 子类中被调用

转载 作者:行者123 更新时间:2023-11-28 13:29:17 25 4
gpt4 key购买 nike

UITableViewController

numberOfSectionnumberOfRowsInSection 被调用,但 cellForRow 没有。可能是什么原因 ?下面是 tableViewController 的代码。

class GlobalSearchTableViewController: UITableViewController {

/// MARK: Properties

/// Delegate
weak var delegate: GlobalSearchTableViewControllerDelegate?

private var state = GlobalSearchTableState(searchResults: [])

override func viewDidLoad() {
super.viewDidLoad()

tableView.estimatedSectionFooterHeight = 60
tableView.sectionFooterHeight = UITableView.automaticDimension

tableView.estimatedRowHeight = 60
tableView.rowHeight = UITableView.automaticDimension
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
}

override func numberOfSections(in tableView: UITableView) -> Int {
return 2
}

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 10
}

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
return UITableViewCell()
}

extension GlobalSearchTableViewController: GlobalSearchTablePresenter {

func present(state: GlobalSearchTableState) {
tableView.reloadData()

}

最佳答案

尝试返回单元格

 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

var cell : UITableViewCell!
cell = tableView.dequeueReusableCell(withIdentifier: "cell")

cell.textLabel?.text = dataArray[indexPath.row]

return cell
}

关于ios - tableView(_ tableView : UITableView, cellForRowAt indexPath: IndexPath) 没有在 UITableViewController 子类中被调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57706245/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com