我有一个单元格和一个NSIntger
,计算字符串中的行数。例如:单元格的宽度设置其中的行数
case 1:
NSString *string = @"abcde\nfghijk\nlmnopq\nrstu";
NSInteger length = [[string componentsSeparatedByCharactersInSet:
[NSCharacterSet newlineCharacterSet]] count];
cell.detailTextLabel.text = [NSString stringWithFormat:string];
cell.detailTextLabel.numberOfLines = length;
break;
此代码在- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
。
如何设置单元格宽度为NSIntger
长度?
你想要单元格宽度或单元格高度? – Abhishek 2012-07-05 14:26:32
这个问题很含糊。我也没有看到'[NSString stringWithFormat:string]'的原因... ... – 2012-07-05 14:27:37
啊..是的....抱歉。我想要细胞的高度。 和@ H2CO3 - 我只是对代码进行抽样。 – theShay 2012-07-05 14:29:30