ios - UITableViewCells 没有正确创建?
问题描述
我正在使用 Storyboard 创建 UITableView,但是在创建自定义单元格时它没有正确创建。请参阅下面的屏幕
] 1
在此屏幕中,另一个以白色显示的新视图。这仅在 Swift 中发生。我清楚地检查了我的原型单元格中只有两个标签。没有第三种观点。
我的代码是
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// create a new cell if needed or reuse an old one
let cell = tableView.dequeueReusableCell(withIdentifier: "cell") as! TableViewCellClass
cell.permissionClassTitleLbl.text = titleArray[indexPath.row]
cell.permissionClassDescLbl.text = descArray[indexPath.row]
cell.permissionClassDescLbl.numberOfLines = 0
// cell.textLabel?.backgroundColor = UIColor.blue
return cell
}
我的故事板 ViewController 屏幕是。
] 2
] 3
但是当我写cell.textLabel?.backgroundColor = UIColor.blue这个代码时,第三个视图消失了。为什么我不知道的原因。请参阅下面的屏幕
] 4
我在整个项目中为所有 TableViewCell 使用 Single TableViewCell 类。
解决方案
推荐阅读
- c# - YouTube API“每天查询”超过约 3 小时
- admob - 如何从商品详情中删除“包含广告”
- java - 尝试打开 GUI 时出现 org.bukkit.command.CommandException
- c# - 按多列分组为对象和相关列表
- amazon-web-services - 如何从 AWS CLI 创建 Amplify React 应用程序
- python - 我的方块怎么不动?我向箭头键发送垃圾邮件,但代码没有给出错误,只是没有按照预期的方式工作
- javascript - 按日期排序,每 24 小时有限制条目
- sql - 在oracle sql的计算列中将十进制值转换为非十进制
- autodesk-forge - 如何获取超过 100 个存储桶对象?如何列出所有存储桶对象?
- linux - Linux 快照应用程序