gpt4 book ai didi

ios - swift - cellForRowAt 从未调用过

转载 作者:行者123 更新时间:2023-11-28 15:35:02 26 4
gpt4 key购买 nike

我在 UITableViewController 中创建 TableView 时遇到问题。行数返回非零数,高度在 Storyboard 中设置。但是 cellForRowAt永远不会被调用。

这是代码:

View Controller :

import UIKit

class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {

@IBOutlet weak var tableView: UITableView!


override func viewDidLoad() {
super.viewDidLoad()

// Do any additional setup after loading the view, typically from a nib.
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "articleCell", for: indexPath) as! ArticleCell

cell.title.text = "THIS IS A TESTE"
cell.desc.text = "THIS IS A TESTE"

return cell
}


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

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

我的代码有什么问题吗?

最佳答案

在你看来Didload make

yourtableView.delegate = self
yourtableView.dataSource = self

不要忘记拉出您的 tableView 的引用 socket 。
enter image description here

关于ios - swift - cellForRowAt 从未调用过,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44376040/

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