2017-06-12 197 views
0

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

包含1个TableView和1个表格单元格的故事板 自定义Tablecell类(TableViewCell_Prototyp),它通过(强)IBoutlets连接到故事板。 View Controller类,在下文中进行描述。

我的ViewController类连接到3个超类: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通过插座连接到TableViewCell_Prototype自定义类。

+2

什么是完整的错误消息?哪一行代码正在导致错误? – rmaddy

+0

libC++ abi.dylib:以NSException类型的未捕获异常终止 –

回答

0

如果这是所有的代码,我会检查你的原型细胞的标识符匹配“picCell”正好和它的类设置为TableViewCell_Prototyp

我觉得@Gereon是正确的,你需要有一个出列不同的方法。

拥有类TableViewCell_Prototyp是不够的 - 您需要将其设置为故事板文件中的单元格。单击故事板中的单元格并将其设置在“标识”选项卡中。

+0

它是。我将复杂性降到了最低限度,但仍然无法正常工作。您可以在下面找到TableViewCell_Protoyp类。 –

+0

import UIKit class TableViewCell_Prototyp:UITableViewCell { @ IBOutlet var shoutPic:UIImageView! @ IBOutlet var shoutText:UILabel! 倍率FUNC awakeFromNib(){ super.awakeFromNib() //初始化代码 } 倍率FUNC的setSelected(_选自:布尔,动画:BOOL){ super.setSelected(选择,动画:动画) //为选定状态配置视图 } } –

1

当你有你的tableView注册的自定义表格单元格类,最好使用dequeueReusableCell(withIdentifier:for:)出列他们,就像这样:

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