自定义UITableViewCell多分区固定与数据源数据重用混乱问题
在使用UITableView多分区时,某分区内为固定内容,其他分区为数据源内容。当
UITableView滚动时,固定内容与数据源内容发生了重叠,这是则需要用到下列方法:
其中GKTableViewCell为自定义的UITableViewCell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *reuseIdentifier =@"reuseIdentifier";
UITableViewCell *cell1 = [tableView dequeueReusableCellWithIdentifier:ruse];
if (!cell1) {
cell1 = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:reuseIdentifier];
}else{
for (UIView *view in cell1.contentView.subviews) {
[view removeFromSuperview];
}
}
GKTableViewCell *cell = [GKTableViewCell cellWithTableView:tableView];
switch (indexPath.section) {
case 0:
{
UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)];
imageView.image = [UIImage imageNamed:@"1.png"];
[cell.contentView addSubview:imageView];
return cell1;
}
break;
case 1:
{
cell.showLabel = self.dataSource[indexPath.row];
return cell;
}
break;
default:
break;
}
return nil;
}
这样你就可以随心所欲了、、、、、、