菜鸟请教cell设计问题

stranger_han 2011-07-03 07:35:27
cell分成两列显示,第一列是titlelabel,第二列是两列多行的detaillabel(这个label的行数根据array中保存的数量来定)
textvalue是一个nsstring:物品名称,申领数量;计算器,0;
最后显示是在titlelabel中老是多显示():(一对括号加一个冒号),不知道是为什么,请大侠指导,非常感谢。


UILabel *titleLabel = (UILabel *)[cell.contentView viewWithTag:kTagTitleLabel];
titleLabel.text = @"物品详情";
if (textValue != nil) {

NSUInteger textLength = [textValue length];


while( [textValue length] != 0) {

NSMutableDictionary *textDic = [[NSMutableDictionary alloc] initWithCapacity:10];


NSInteger locoal = [textValue rangeOfString:@","].location;
NSString *name = [textValue substringToIndex:locoal];
[textDic setObject:name forKey:@"name"];


NSString *temp = [textValue substringFromIndex:locoal+1];
textValue = temp;
textLength = [textValue length];
locoal = [textValue rangeOfString:@";"].location;
NSString *value = [textValue substringToIndex:locoal];
[textDic setObject:value forKey:@"value"];

temp = [textValue substringFromIndex:locoal+1];
textValue = temp;

NSLog(@"textvalue length = %d", [textValue length]);

[textArray addObject:textDic];
[textDic release];


}

for (NSUInteger i = 0; i < [textArray count]; i++) {

NSMutableDictionary *dic = [[NSMutableDictionary alloc] initWithCapacity:10];
//get value from text array
dic = [textArray objectAtIndex:i];
NSString *name = [dic objectForKey:@"name"];
NSString *value =[dic objectForKey:@"value"];

UILabel *detailLabel1 = (UILabel *)[cell.contentView viewWithTag:(kTagLastRowLineView+(i*2+1))];
UILabel *detailLabel2 = (UILabel *)[cell.contentView viewWithTag:(kTagLastRowLineView+(i*2+2))];

detailLabel1.text = name;
detailLabel2.text = value;

}

}
...全文
66 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
咸清 2011-07-04
  • 打赏
  • 举报
回复
NSInteger locoal = [textValue rangeOfString:@","].location;
NSString *name = [textValue substringToIndex:locoal];
[textDic setObject:name forKey:@"name"];


NSString *temp = [textValue substringFromIndex:locoal+1];
textValue = temp;
textLength = [textValue length];
locoal = [textValue rangeOfString:@";"].location;
NSString *value = [textValue substringToIndex:locoal];
[textDic setObject:value forKey:@"value"];


这里打印一下

29,031

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧