cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
2.cellforRow方法里每次调用,没有cell则创建,有则删除重新创建
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath{
UITableViewCell *cell=nil;
static NSString *reuse=@"cell";
if (cell==nil) {
cell=[[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefa ult reuseIdentifier:reuse] autorelease];
}else{
while ([cell.contentView.subviews lastObject] != nil) {
[(UIView*)[cell.contentView.subviews lastObject] removeFromSuperview]; //删除并进行重新分配
}
}
cell.textLabel.text=@"cell";
return cell;
}
3.
if (cell ==
nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValu e1 reuseIdentifier:cellName] autorelease];
}
for (UIView * view in cell.contentView.subviews) {
[view removeFromSuperview];
}
[cell.contentView addSubview:label];