在UILabel中显示indexOfObject

时间:2013-05-23 21:26:49

标签: uilabel type-conversion

我试图在NSArray UILabel中显示UITabelViewCell中的对象数量,作为UILabel *numberLabel = (UILabel *)[cell viewWithTag:103]; numberLabel.numberOfLines = [self.inputValues indexOfObject:inputValue]; NSLog(@"rownumber is: %d", numberLabel.numberOfLines); 的一部分:

NSLog

{{1}}为我提供了正确的号码,但标签只显示默认的标题值。我在这里错过了什么?没有错误。

2 个答案:

答案 0 :(得分:4)

您需要设置标签的text属性。例如:

NSUInteger index = [self.inputValues indexOfObject:inputValue];
numberLabel.text = [NSString stringWithFormat:@"Row %lu", (unsigned long)index];

但是,您似乎可以使用单元格索引路径中的row,如下所示:

numberLabel.text = [NSString stringWithFormat:@"Row %ld", (long)indexPath.row];

答案 1 :(得分:1)

我很确定你想要的是:

UILabel *numberLabel = (UILabel *)[cell viewWithTag:103];
numberLabel.text = [NSString stringWithFormat:@"%d", [self.inputValues indexOfObject:inputValue]];
NSLog(@"rownumber is: %d", numberLabel.numberOfLines);
相关问题