2011-07-10 12 views
0

cellforrowatindexpathを構築し、私はチャットアプリを構築し、私は少し問題を抱えている:カスタムUITableViewCellの

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 

static NSString *CellIdentifier = @"UserCell"; 


UserCell *cell = (UserCell *) 
[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if (nil == cell) { 
    NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"UserCell" 
                  owner:nil 
                  options:nil]; 
    for (id currentObject in topLevelObjects) { 
     if ([currentObject isKindOfClass:[UITableViewCell class]]) { 
      cell = (UserCell *) currentObject; 
      break; 
     } 
    } 
} 

NSString *nameValue = [self.names objectAtIndex:indexPath.row]; 
NSString *statusValue = [self.usersStatus objectAtIndex:indexPath.row]; 
cell.name.text = nameValue; 
cell.status.text = statusValue; 


return cell; 

}

とあらゆる細胞に私は隠されているどのようなラベルを持っており、中:

-(void)chatHandlerNewMsg:(ChatHandler*)chat withInt:(NSString*)userId{ 
NSInteger tmp = [self.usersID indexOfObject:userId]; 
NSIndexPath *index = [NSIndexPath indexPathForRow:tmp inSection:0]; 
UserCell *cell = (UserCell*)[self.table cellForRowAtIndexPath:index]; 
[cell.newMsg setHidden:NO]; 
[self.table reloadData]; 

}

私は新しいMSGをチェックし、もしそうなら、私は隠されたから示さへuilabelをもたらします。

UserCell *cell = (UserCell*)[self.table cellForRowAtIndexPath:index]; 

答えて

0

史上:テーブルビュー内だけでなく、私たちが選択した特定のもので、他の細胞内

問題は、テーブルビューを表示することを、このuilabelである(これはデフォルトでは非表示になっていること)前の行が設定した状態を手動でリセットする必要があるセルをデキューします。

cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if (cell) { 
    //Reset cell state (make label hidden) 
} 
else 
{ 
    //Create new cell and configure (hide labels) 
} 

//Set any common attributes here (title) 

return cell; 
関連する問題