ios – 如何引用cellForRowAtIndexPath之外的单元格

ios – 如何引用cellForRowAtIndexPath之外的单元格,第1张

概述我正在尝试更新外部单元格中的标签 override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell 通过使用 let cell = tableView.dequeueReusableCellWithIdentifier("cell", fo 我正在尝试更新外部单元格中的标签

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

但不会返回错误,但标签cell.time.text未更新.

解决方法 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的可见单元格,除了单元格为零

总结

以上是内存溢出为你收集整理的ios – 如何引用cellForRowAtIndexPath之外的单元格全部内容,希望文章能够帮你解决ios – 如何引用cellForRowAtIndexPath之外的单元格所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1003391.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存