更新自定义UITableView单元格中的标签 [英] Update label in custom UITableView Cell

查看:99
本文介绍了更新自定义UITableView单元格中的标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要通过单击同一单元格中的按钮"来更新标签.为什么我的代码不起作用?

I need to Update an label by clicking on an Button in the same cell. Why does my code doesn't work ?

@IBAction func actionFaveUnfave(sender: AnyObject) {
    let cell = self.tableView.cellForRowAtIndexPath(sender.indexPath)
    println(cell?.labelFavedTimes)

   cell.labelFavedTimes = "22"}

推荐答案

cell?.labelFavedTimes.text = "22"

顺便说一句 self.tableView.cellForRowAtIndexPath(sender.indexPath) 如果看不见单元格,则可以返回nil

BTW self.tableView.cellForRowAtIndexPath(sender.indexPath) can return nil if cell is not visible

这篇关于更新自定义UITableView单元格中的标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆