ios - 表视图项目未显示
问题描述
我是 iOS 开发的新手。
我正在尝试使用 显示我的应用程序中的项目列表UITableView
,但项目未显示:
我的视图控制器:
class HistoryView: UIViewController, UITableViewDataSource, UITableViewDelegate {
@IBOutlet weak var tableView: UITableView!
let cellReuseIdentifier = "cell"
@IBOutlet weak var noDataLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
tableView.register(HistoryTableViewCell.self, forCellReuseIdentifier: "historyCell")
tableView.delegate = self
tableView.dataSource = self
self.noDataLabel.isHidden=true
}
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 10
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "historyCell") as! HistoryTableViewCell
cell.nickname?.text = "name"
return cell
}
}
我的表格视图单元格:
class HistoryTableViewCell: UITableViewCell {
@IBOutlet weak var nickname: UILabel!
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
}
}
关于发生了什么的任何建议?
解决方案
推荐阅读
- c# - 如何将数据表从 C# 传递到 SQL Server 存储过程
- python - groupby 之后的 Pandas Keyerror
- python - ValueError:没有为任何变量提供梯度 - 使用自定义损失函数和 run_eagerly=True 训练回归 keras 模型
- javascript - this.parentElement 和 element.parentElement 有什么区别?
- python - 如何让 Visual Studio 使用我选择的环境运行?
- c - Obtain a vertex after a transform in OpenGL?
- google-api - 创建活动系列的问题
- django - 如何在 django 中以 pbkdf2_sha256 格式存储用户密码?
- python - 如何从 statsmodels.tsa.api 中提取系数矩阵
- javascript - 如何结合父 SVG、子 SVG、PNG 和工具提示?