ios - 自定义单元格不出现在 tableView
问题描述
我的自定义单元格没有出现在我的表格视图中,我没有找到任何答案。
这是我的 listController :
extension MatchListViewController: UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return matchArray.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell = tableView.dequeueReusableCell(withIdentifier: "MatchCell", for: indexPath) as? MatchTableViewCell else {
return UITableViewCell()
}
let match = matchArray[indexPath.row]
cell.configure(nomDuMatch: match.matchName, scoreFinal: match.finalScore)
return cell
}
}
(我已经通过情节提要配置了 dataSourceDelegate)
customCell 标识符是正确的,我真的不明白为什么启动时什么都没有出现。
随时问我更多图片/信息!
编辑 :
解决方案
你需要实施
func tableView(_ tableView: UITableView,
heightForRowAt indexPath: IndexPath) -> CGFloat {
return 100 // or any value
}
或使用自动单元格并在 IB 中正确设置约束,因为您似乎有约束问题并将其设置为viewDidLoad
tableView.estimatedRowHeight = 100
tableView.rowHeight = UITableViewAutomaticDimension
推荐阅读
- postgresql - postgreSQL : oracle sqlerrm 相当于 postgres
- yii - yii1.1出现“CDbCommand failed to execute the SQL statement FOREIGN KEY”错误信息如何处理
- c# - 根据标准比较两个对象
- java - 在 @RestController 端点中共享 @ConfigurationProperties bean
- java - 并行流如何“知道”使用封闭的 ForkJoinPool?
- android - 有没有办法让 Android 原生 sip 堆栈支持所有 android 设备上的 voip?
- netbeans - TomEE - Netbeans - 项目外的文件夹
- spring-cloud-contract - 我们能否只使用 Groovy Contract DSL 文件而不拥有整个 Producer 代码来创建存根 JAR
- wordpress - Wordpress '调用未定义的函数 cynic_theme_finder()'
- c# - 从 C# 桌面应用程序使用电子邮件发送附件(即.Pdf 文件)的问题