29,041
社区成员
发帖
与我相关
我的任务
分享- (ChatCustomCell1 *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
static NSString *identifier = @"tableViewIdentifier";
ChatCustomCell1 *cell = [tableView dequeueReusableCellWithIdentifier: identifier];
if(cell == nil)
{
[self.cellNib instantiateWithOwner:self options:nil];
cell = tmpCell;
self.tmpCell = nil;
}
NSInteger row = [indexPath row];
ChatMessage *chatMessage = (ChatMessage *)[chatMessageArray objectAtIndex:row];
cell.messageLable.text = chatMessage.message;
// 设置cell
if (chatMessage.fromMyself)
{
UIImage *image = [UIImage imageNamed:@"online.png"];
cell.leftFaceImageView.image = image;
[image release];
[cell.leftTimeLable setText:chatMessage.messageTime];
UIImage *image1 = [UIImage imageNamed:@"bubule2"];
cell.messageBackImage.image = image1;
[image1 release];
AppDelegate *myApp = [[UIApplication sharedApplication] delegate];
cell.leftNameLable.text = myApp.loginName;
}
else
{
UIImage *image = [UIImage imageNamed:@"online.png"];
cell.rigthFaceImageView.image = image;
[image release];
cell.rightTimeLable.text = chatMessage.messageTime;
UIImage *image1 = [UIImage imageNamed:@"bubule1"];
cell.messageBackImage.image = image1;
[image1 release];
cell.rightNameLable.text = chatMessage.senderName;
}
cell.messageLable.textAlignment = NSTextAlignmentCenter;
cell.messageLable.font = [UIFont systemFontOfSize:[UIFont systemFontSize]];
[cell.messageLable setNumberOfLines:0];
return cell;
}
static BOOL register = NO
if(!register)
{
NSBundle *bundle = [NSBundle bundleForClass:[ChatCustomCell1 class]];
UINib *cellNib = [UINib nibWithNibName:@"ChatCustomCell1" forBundle: bundle];
[tableView registerNib:cellNib forCellReuseIdentifier:identifier];
}
ChatCustomCell1 *cell = [tableView dequeueReusableCellWithIdentifier: identifier];
是的,你说的有道理,给个建议怎么释放掉呗。