cell 的数据( 包含label,button等控件)总是为nil
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// Table view cells are reused and should be dequeued using a cell identifier.
guard let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath) as? ScanResultTableViewCell else {
fatalError("The dequeued cell is not an instance of ScanResultTableViewCell.")
}
// Fetches the appropriate meal for the data source layout.
let cellData = scanResults[indexPath.row]
cell.scanResultNameLabel?.text = cellData.deviceName
cell.scanResultLogoImageView?.image = cellData.logo
return cell
}
debug查看结果,发现cell.scanResultNameLabel为nil,可是我在storyboard明明在cell中拖进了一个label,求教大神?
// Table view cells are reused and should be dequeued using a cell identifier.
guard let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath) as? ScanResultTableViewCell else {
fatalError("The dequeued cell is not an instance of ScanResultTableViewCell.")
}
// Fetches the appropriate meal for the data source layout.
let cellData = scanResults[indexPath.row]
cell.scanResultNameLabel?.text = cellData.deviceName
cell.scanResultLogoImageView?.image = cellData.logo
return cell
}
debug查看结果,发现cell.scanResultNameLabel为nil,可是我在storyboard明明在cell中拖进了一个label,求教大神?
...全文
相关推荐
根据Label的内容确定Cell高度
根据每一行要显示的内容来确定CELL的高度 里面一个LayoutHelper的方法可以直接调用
swift-倒计时控件包括按钮倒计时label倒计时以及在cell中的倒计时
倒计时控件,包括按钮倒计时,label倒计时以及在cell中的倒计时
ios-简单地cell自适应.zip
我上传的demo都很简单,只为简单到每个人都可以看得懂,让后凭借自己的能力写一个
ios-计算label的高度.zip
动态计算label的高度返回cell的高度
UITableViewCell根据文字自动改变cell和lable的高度
UITableViewCell根据文字自动改变cell和lable的高度 boundingRectWithSize


