objective-c - 如何从table向cell中传值?

浏览:52日期:2023-12-09

问题描述

问题是这样的,我现在想往自定义cell中传入几个判断条件,用以判断是否添加图片标签等等,请问能否在返回cell时添加用属性给cell中传值

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {tabelViewCell1 *cell = [tableView dequeueReusableCellWithIdentifier:@'cell'];NSDictionary *dic = _arr[indexPath.row];cell.name.text = dic[@'userinfo'][@'uname'];[cell.imgView sd_setImageWithURL:[NSURL URLWithString:dic[@'userinfo'][@'icon']]];cell.songId = @'ddd';return cell; }

songId并不能传进cell中

问题解答

回答1:

在tabelViewCell1中你定义songId了吗?检查一下吧 是不是代码其他地方有问题。

相关文章: