这个问题困扰两个星期了,求大神帮忙解决。我自己写了一个cell继承了UITableViewCell,然后在cell里面加了贴图和标签,以达到项目需要的效果。问题来了。。。在真机测试的时候,tableView往下拖,刷新新的cell会卡。而且调试发现,不停的上拉下拉。内存会不断增加。上代码
- (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;