ios - UITableView 单元格不显示所有数据
问题描述
UITableView
从 JSON 文件填充第一个。一切似乎都在加载,没有崩溃,但表格单元格不包含所有数据。它们在底部被切断。
HeroViewController
class HeroViewController: UIViewController, UITableViewDataSource, UITableViewDelegate, WCSessionDelegate {
// code
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return messageObject.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let tableCell : HeroTableViewCell = tableView.dequeueReusableCell(withIdentifier: "MessageCell") as? HeroTableViewCell ?? HeroTableViewCell(style: UITableViewCell.CellStyle.default, reuseIdentifier: "MessageCell")
let row = indexPath.row
let rowObj = messageObject[row]
tableCell.one.text = rowObj.title as String?
tableCell.two.text = rowObj.speaker as String?
tableCell.three.text = rowObj.from as String?
tableCell.four.text = rowObj.to as String?
return tableCell
}
}
解决方案
你的细胞似乎没有足够的高度。您可以通过覆盖此方法来设置它:
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 100; //return the cell height you desire
}
推荐阅读
- css - 如何处理/使用带有 css 变量的路径图像?角
- ssl-certificate - 使用 cloudflare 及其托管在 infinity free(免费帐户)上的 ssl 证书托管我的网站时出现问题
- gitlab - 当我想更改分支时出现 Git Erro
- http - 更好地使用 URLSession 实时下载连续的 HTTP-Multipart 流
- c# - c#在DataReceived内部调用另一个方法时,串行端口读取被锁定
- google-sheets - 在 Google 表格中勾选复选框时自动创建新行
- powershell - 自动将字符串传递给 powershell 用户输入
- vba - CurrentDb.Execute 错误 3061 和 DAO.Recordset 错误
- angular - 打字稿:如果我忽略循环依赖会发生什么
- docker - Docker - 错误:adduser:UID 0 已在使用中