-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
// NSLog(@"msgcnt123 %@\n",[messageCount objectAtIndex:indexPath.row]);
NSArray *seperateArray = [[clist objectForKey:[[clist allKeys]objectAtIndex:indexPath.row]]componentsSeparatedByString:@"@"];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
// NSLog(@"key %@\n",[[clist allKeys]objectAtIndex:indexPath.row]);
cell.textLabel.text = [seperateArray objectAtIndex:0];
// cell.textLabel.text = [contactlist objectAtIndex:indexPath.row];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
// NSLog(@"sep %@\n",seperateArray);
if (![[seperateArray objectAtIndex:1] isEqualToString:@"0"]) {
NSLog(@"msgCount %@\n",[seperateArray objectAtIndex:1]);
lblCnt = [[UILabel alloc]initWithFrame:CGRectMake(260, 13, 20, 20)];
lblCnt.backgroundColor = [UIColor lightGrayColor];
lblCnt.textColor = [UIColor blackColor];
lblCnt.text = [seperateArray objectAtIndex:1];
lblCnt.textAlignment = UITextAlignmentCenter;
lblCnt.layer.masksToBounds = YES;
lblCnt.layer.cornerRadius = 2.0f;
[cell.contentView addSubview:lblCnt];
lblCnt.tag = 1000;
}
else
{
/*NSLog(@"msgCount1 %@\n",[seperateArray objectAtIndex:1]);
[lblCnt removeFromSuperview];
lblCnt.hidden = YES;*/
for (UIView *view in [cell.contentView subviews])
{
if (view.tag == 1000)
{
[view removeFromSuperview];
}
}
}
return cell;
}
我在UITableView.The标签每个contact.My视图名称显示接收到的邮件数的标签中显示联系人的名字是chatViewcontroller.If我在认为标签计数不更新。例如:对于联系人姓名“约翰”标签计数是“2”。当约翰收到一条消息,标签计数应该更新为“3”。它不会发生这种情况。如果我从另一个视角移动,它会更新。是否有可能更新tableView chatviewController本身?更新标签
刚刚重装该表同时更新 – Venkat 2013-02-15 13:11:32
ü意味着[实现代码如下reloadData]。它不工作 – user2003416 2013-02-15 13:13:23