UITableView中的自定义单元格出现错误
我现在完全卡住了。我搜索了所有的地方,似乎无法找出我为什么一直收到这个错误-更糟糕的是,错误日志只显示UITableView中的自定义单元格出现错误,uitableview,swift,xcode6,Uitableview,Swift,Xcode6,我现在完全卡住了。我搜索了所有的地方,似乎无法找出我为什么一直收到这个错误-更糟糕的是,错误日志只显示(lldb) 我正在尝试在表中显示自定义单元格。每个单元格都有一个名为lblRouteNumber的主标签,然后两侧各有两个标签,lblLeftStation和lblRightStation 在表视图中注册自定义单元格类: self.tblMain.registerClass(CustomTableViewCell.classForCoder(),forCellReuseIdentifier:“
(lldb)
我正在尝试在表中显示自定义单元格。每个单元格都有一个名为lblRouteNumber
的主标签,然后两侧各有两个标签,lblLeftStation
和lblRightStation
在表视图中注册自定义单元格类:
self.tblMain.registerClass(CustomTableViewCell.classForCoder(),forCellReuseIdentifier:“cellTemplate”)
My cell creator方法:
func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell!
{
var cell = tblMain.dequeueReusableCellWithIdentifier("cellTemplate", forIndexPath: indexPath) as CustomTableViewCell
cell.lblRouteNumber.text = "Routing"
cell.lblLeftStation.text = "LEFT"
cell.lblRightStation.text = "RIGHT"
return cell
}
和我的自定义单元格类:
class CustomTableViewCell: UITableViewCell {
@IBOutlet var lblRouteNumber : UILabel
@IBOutlet var lblLeftStation : UILabel
@IBOutlet var lblRightStation : UILabel
init(style: UITableViewCellStyle, reuseIdentifier: String) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
}
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
应用程序在线崩溃
var cell=tblMain.dequeueReusableCellWithIdentifier(“cellTemplate”,forIndexPath:indexPath)作为CustomTableViewCell
init(style: UITableViewCellStyle, reuseIdentifier: String) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
}
如果我尝试为其中的标签分配任何内容,我会得到无法展开选项。无错误
从CustomTableViewCell中删除以下代码
init(style: UITableViewCellStyle, reuseIdentifier: String) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
}
那么我已经在这里回答了这个问题
也试过了。。。不走运。我几乎复制了你的东西,但是用我的标签和东西你能把IB插座连接好吗?是的,先生。我只是仔细检查了一下。你能在你的问题中添加错误的截图吗?让我们来看看。