【发布时间】:2015-12-16 10:21:32
【问题描述】:
我目前遇到了 UITableView 的问题。
我从 json 文件中获取一些数据并将它们放入表格视图中,但表格视图有一个奇怪的反应。 当我打开应用程序时,它在单元格中没有任何内容,当我进一步向下然后回到顶部时,它会出现应该出现在单元格内的内容。 如果我下去,它会使单元格内的文本消失。
代码
in ViewDidLoad
let nib = UINib(nibName: "homeTableViewCell", bundle: nil)
// Register the nib for reusing within the tableview with your reuseidentifier
self.activitiesTable.registerNib(nib, forCellReuseIdentifier: "homeCell")
self.activitiesTable.delegate = self
self.activitiesTable.dataSource = self
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("homeCell", forIndexPath: indexPath) as! homeTableViewCell
cell.lblContentHomeCell.text = "test"
return cell
}
这是模拟器的截图。
即使我在每个单元格中正常写“测试”仍然有同样的问题。 单元格是自定义单元格。 有没有人遇到同样的问题并找到了解决方案?非常感谢您的帮助。
【问题讨论】:
标签: uitableview swift2 ios9