[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];
当我们的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];
相关文章推荐
- [转]UISearchbar去除背景色的方法…
- [2015-03-16]改变UITableView的hea…
- [2015-03-16]解决UITableViewStyle…
- [2013-03-27]iOS之UITextField和U…
- 【2013-5-8】除去UIBarButtonItem…
- [2014-03-31]使用NSOperationQueue…
- UIScrollView 原理详解(转)
- 学习UIPickerView中遇到的小问题
- 62. Unique Paths&机器人走方格I
- IOS学习之自定义UITableViewCell
- IOS学习之UIButton
- 【IOS】扩展UIImageViewEx实现:手…
- 基于squashfs的gluebi文件系统开发
- iOS UIFont 字体名字大全
- IOS开发之UIFont应用
- StringBuilder or StringBuffer
- 如何自己编写一个easyui插件
- TrueCrypt 7.1a Hashes
- 关于用Requests模块页面编码的相关
- 设计模式学习--建造者模式