Home  >  Q&A  >  body text

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

问题是这样的,我现在想往自定义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中

仅有的幸福仅有的幸福2754 days ago755

reply all(1)I'll reply

  • PHP中文网

    PHP中文网2017-04-28 09:08:11

    Have you defined songId in tabelViewCell1? Check to see if there is a problem elsewhere in the code.

    reply
    0
  • Cancelreply