我正在尝试更新外部单元格中的标签
override func tableView(tableView: UITableView,cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
通过使用
let cell = tableView.dequeueReusableCellWithIdentifier("cell",forIndexPath: indexPath) as! Cell
在另一个功能.但是,我一直在收到错误.因此,我试图通过使用let cell = Cell()来引用单元格,但是我意外地发现错误为nil.最后,我试过了
let cell = tableView.dequeueReusableCellWithIdentifier("cell") as! Cell
解决方法
Swift 3.0&斯威夫特4
let indexPath = IndexPath(row: 0,section: 0) let cell = tableView.cellForRow(at: indexPath)
斯威夫特2.3
let indexPath = NSIndexPath(forRow: 0,inSection: 0) let cell = tableView.cellForRowAtIndexPath(indexPath)
注意: – 在上述方法的帮助下,你只能得到tableView的可见单元格,除了单元格为零