uitableview - UITableView 将行数调整为 StoryBoard 中的行数
问题描述
您好,我正在尝试将 tableView 中的行数自动修改为 = 我的数组中的计数。数据工作正常,并且相应地加载行数。然而,表格本身总是显示 4 行,它不会加载更多,即使加载较少也不会显示更少,正如您在图片中看到的那样。下面是我的脚本和设置。
extension FirstViewController: UITableViewDelegate {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
print("click")
}
}
extension FirstViewController: UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// let a = UserDefaults.standard.integer(forKey: "RunwayRows")
// return a
return runways.count
}
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
cell.textLabel?.text = runways[indexPath.row].ident1
print(runways.count)
return cell
}
}
解决方案
推荐阅读
- python - 如何优化此 Python 代码?
- php - 使用数据库登录 Symfony
- reactjs - 如何为 React Material UI 实现全局主题?
- javascript - javascript xmlhttprequest 总是获得状态 0
- c++ - c ++:为什么整数前面的减号信号会给出一个疯狂的数字?
- django - Django allauth 出错 is_safe_url() got an unexpected keyword argument 'allowed_hosts'
- c - STM32 VCP驱动——指针失效只有优化
- node.js - 列出应用的 sequelize 迁移
- python - 无法在 Windows 8.1 上安装 python-poppler-qt5
- ruby - 如何卸载 dart sass?