您的位置:首页 > 产品设计 > UI/UE

[2014-04-21]解决uitableviewcell…

2015-06-26 09:20 549 查看
第一种情况:

当我们的uitableview为透明或者判断cell是否为空时,会发现uitableveiwcell会出现重叠,下面为自己的解决办法,提供给各位参考

-(UITableViewCell
*)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath*)indexPath{

UITableViewCell *cell=nil;

static
NSString *reuse=@"cell";

if
(cell==nil) {

cell=[[[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuse]
autorelease];

}else{

while ([cell.contentView.subviews lastObject] !=
nil) {

[(UIView*)[cell.contentView.subviews
lastObject]
removeFromSuperview]; //删除并进行重新分配

}

}

cell.textLabel.text=@"cell";

return
cell;
}

第一种情况:

解决UIlable在tablecell上更新重叠的问题

if
(cell == nil) {

cell = [[[UITableViewCell
alloc] initWithStyle:UITableViewCellStyleValue1
reuseIdentifier:cellName] autorelease];

}

for
(UIView * view in
cell.contentView.subviews) {

[view
removeFromSuperview];

}

[cell.contentView addSubview:label];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: