最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

[已解决]swift didSelectRowAtIndexPath中如何获得对应的cell

Uncategorized crifan 7799浏览 0评论
在折腾:
[已解决]swift切换视图(控制器)时传递数据
期间,需要在UITableView中的
    func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
 去获得对应的cell,然后获得cell中的某个数据
[解决过程]
1.搜:
swift didselectrowatindexpath get cell
参考:
然后用:
    func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
        print("didSelectRowAtIndexPath indexPath = \(indexPath)")

        let curCell = self.tableView!.cellForRowAtIndexPath(indexPath)!
        print("curCell=\(curCell)") //curCell=<JianDao.ConversationTableViewCell: 0x7fdb5485f000; baseClass = UITableViewCell; frame = (0 114; 375 57); text = '#羽毛球俱乐部'; autoresize = W; layer = <CALayer: 0x7fdb536710e0>>

即可。

[总结]
didSelectRowAtIndexPath中,直接就有系统函数支持获得对应cell:
let curCell = self.tableView.cellForRowAtIndexPath(indexPath)
 直接用即可。

转载请注明:在路上 » [已解决]swift didSelectRowAtIndexPath中如何获得对应的cell

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
79 queries in 0.162 seconds, using 21.99MB memory