gpt4 book ai didi

ios - Swift:表格 View - Signal SIGABRT

转载 作者:行者123 更新时间:2023-11-28 15:33:39 25 4
gpt4 key购买 nike

根据我的其他线程,我的代码中有一个信号 SIGABRT 错误。代码包括:

包含 1 个 TableView 和 1 个 Table Cell 的 Storyboard自定义 Tablecell 类 (TableViewCell_Prototyp),它通过(强)IBoutlets 连接到 Storyboard。View Controller 类,如下所述。

我的 ViewController 类连接到 3 个父类(super class):UIViewController、UITableViewDelegate、UITableViewDataSource。此外,还实现了 3 个功能。有人能找出错误吗?

override func viewDidLoad() {
super.viewDidLoad()
}

我不知道这里发生了什么。它是默认编写的,因此不会导致任何错误。

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

我只想返回一个表格单元格。

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell (withIdentifier: "picCell") as! TableViewCell_Prototyp
cell.shoutPic.image = #imageLiteral(resourceName: "Bildschirmfoto 2017-06-05 um 10.11.21")
cell.shoutText.text = "Hallooooooooo"
return cell
}

shoutPic 和 shoutText 通过 outlets 连接到 TableViewCell_Prototype 自定义类。

最佳答案

当您为 tableView 注册了自定义表格单元格类时,最好使用 dequeueReusableCell(withIdentifier:for:) 将它们出列,如下所示:

let cell = tableView.dequeueReusableCell(withIdentifier: "picCell", for: indexPath) as! TableViewCell_Prototyp

关于ios - Swift:表格 View - Signal SIGABRT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44508431/

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