在模拟测试环境,由于是局域网,TableView里面的图片刷新不那么容易看出来。真拿到真机上,用3G网络测试,就会发现拖拽后(前拽、后拽)都发现图片、CELL在刷新,如果后拽是延时获取图片,那前拽就一定是有问题了。
这个问题的关键还是在UITableViewCell的重用标识,即reuseIdentifier,由于项目有UITableViewCell用到Nib,那么对Cell的标识就很关键,起初,我们用下面的办法处理:
cell = [[[
Mycell alloc
] initWithStyle
:UITableViewCellStyleDefault
reuseIdentifier
:
@"cellid"
] autorelease
];
这种方式是可以,关键是在制作Nib时,那些UILabel,UIImage并未绑定在rootController上,导致界面数据没发直接显示(应该需要额外的代码来实现)。
那应该如何来处理呢。也有两种解决办法:
1.自定义的cell实现reuseIdentifier
-
(
NSString
*)
reuseIdentifier
{
return @ "myIdentifier" ;
}
return @ "myIdentifier" ;
}
2.注册Cell值Key
NSString * cellId = dispCellObj.objid;
...
NSArray * nibObjects = [[NSBundle mainBundle] loadNibNamed:@"MyCell" owner:nil options:nil];
for (id obj in nibObjects) {
if ([obj isKindOfClass:[MyCell class]]) {
cell = obj;
[cell setValue:cellId forKey:@"reuseIdentifier"];
break;
}
}
...
NSArray * nibObjects = [[NSBundle mainBundle] loadNibNamed:@"MyCell" owner:nil options:nil];
for (id obj in nibObjects) {
if ([obj isKindOfClass:[MyCell class]]) {
cell = obj;
[cell setValue:cellId forKey:@"reuseIdentifier"];
break;
}
}
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10531/viewspace-713098/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/10531/viewspace-713098/