这个问题困扰两个星期了,求大神帮忙解决。我自己写了一个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;
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;
}
UItableView卡内存不断增加
{
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;
}
UItableView卡内存不断增加
解决方案 »
- Xcode4.6-->Hello Wolrd疑问
- 在xcode下怎样通过wifi接收和发送数据,需要用到哪些库和哪些类?
- Android平板电脑,可以编译,调试。C和Objact C语言程序么?
- iphone中的相关问题
- 行业外菜鸟救教:关于APP开发
- ios上即时通信一般是通过什么技术实现的?
- 关于框架问题,有没有牛人来看看
- 请教titleLabel.text和currentTitle的一些区别
- iOS友盟分享到qq、QQ空间总是提示打开qq失败,打印出来的信息是send to qq result is 2 求大神帮忙怎么解决!!
- 消息发送语句?
- 为什么字符串压缩之后不是zip包
- 我使用Xcode4.6.3制作应用,教程上说制作好按钮后在按钮上点鼠标右键就可以设置事件了,但为什么我点了后没有反映啊?请高手解答。
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];