我有一个用 JSON 填充的表。它用作日历。单击日期后,下表应填充当天的事件。
这些在找到数据后填充表,但只执行一次。
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return(GlobalVar.TodaysEvents.count)
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "eventCell", for: indexPath) as! WhitelistTableViewCell
cell.startTime.adjustsFontSizeToFitWidth = true
print(GlobalVar.TodaysEventsTimes[indexPath.row])
cell.startTime.text = (GlobalVar.TodaysEventsTimes[indexPath.row] as! String)
cell.Summary.text = GlobalVar.TodaysEvents[indexPath.row] as? String
return(cell)
}
我看过其他类似的帖子,他们使用:
self.tableView.reload()
但是,当我尝试此操作时,它无法识别“tableView”并且根本不起作用。
任何建议将不胜感激,提前致谢
创建对 tableView(新引用插座)的引用,然后执行以下操作:
yourTableView.reloadData()
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句