清除UITableView底部多余的分割线
2014-05-04 11:11
351 查看
第一种方法
1、加方法
-(void)setExtraCellLineHidden: (UITableView *)tableView
{
UIView *view = [UIView new];
view.backgroundColor = [UIColor clearColor];
[tableView setTableFooterView:view];
[view release];
}
2、在
- (void)viewDidLoad
{
[super viewDidLoad];
//设置tableView不能滚动
[self.tableView setScrollEnabled:NO];
//在此处调用一下就可以啦 :此处假设tableView的name叫:tableView
[self setExtraCellLineHidden:self.tableView];
}
在iOS4.3和iOS5.0中通过:值得注意的是在iOS4.3中可以直接设置footer为nil,但是在5.0不行,因为UITableView会默认生成一个Footer。(详见iOS Release Notes中的说明:Returning nil from the tableView:viewForHeaderInSection: method (or its footer equivalent) is no longer sufficient to
hide a header. You must override tableView:heightForHeaderInSection: and return 0.0 to hide a header.)
plain类型的tableview当显示的数据很少时,下面的cell即使不显示数据也会有分割线,可以通过下面这个函数去掉多余的分割线。
- (void)setExtraCellLineHidden: (UITableView *)tableView
{
UIView *view =[ [UIView alloc]init];
view.backgroundColor = [UIColor clearColor];
[tableView setTableFooterView:view];
[view release];
}
当tableview的dataSource为空时,也就是没有数据可显示时,该方法无效,只能在numberOfRowsInsection函数,通过判断dataSouce的数据个数,如果为零可以将tableview的separatorStyle设置为UITableViewCellSeparatorStyleNone去掉分割线,然后在大于零时将其设置为
UITableViewCellSeparatorStyleSingleLine
第二种方法
In viewDidLoad:
更多2
上一篇页面跳转动画设置方法
下一篇iphone
正则表达式使用(NSRegularExpression)
顶
0
1、加方法
-(void)setExtraCellLineHidden: (UITableView *)tableView
{
UIView *view = [UIView new];
view.backgroundColor = [UIColor clearColor];
[tableView setTableFooterView:view];
[view release];
}
2、在
- (void)viewDidLoad
{
[super viewDidLoad];
//设置tableView不能滚动
[self.tableView setScrollEnabled:NO];
//在此处调用一下就可以啦 :此处假设tableView的name叫:tableView
[self setExtraCellLineHidden:self.tableView];
}
在iOS4.3和iOS5.0中通过:值得注意的是在iOS4.3中可以直接设置footer为nil,但是在5.0不行,因为UITableView会默认生成一个Footer。(详见iOS Release Notes中的说明:Returning nil from the tableView:viewForHeaderInSection: method (or its footer equivalent) is no longer sufficient to
hide a header. You must override tableView:heightForHeaderInSection: and return 0.0 to hide a header.)
plain类型的tableview当显示的数据很少时,下面的cell即使不显示数据也会有分割线,可以通过下面这个函数去掉多余的分割线。
- (void)setExtraCellLineHidden: (UITableView *)tableView
{
UIView *view =[ [UIView alloc]init];
view.backgroundColor = [UIColor clearColor];
[tableView setTableFooterView:view];
[view release];
}
当tableview的dataSource为空时,也就是没有数据可显示时,该方法无效,只能在numberOfRowsInsection函数,通过判断dataSouce的数据个数,如果为零可以将tableview的separatorStyle设置为UITableViewCellSeparatorStyleNone去掉分割线,然后在大于零时将其设置为
UITableViewCellSeparatorStyleSingleLine
第二种方法
[code]if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease]; // Drawing our own separatorLine here because I need to turn it off for the // last row. I can only do that on the tableView and on on specific cells. // The y position below has to be 1 less than the cell height to keep it from // disappearing when the tableView is scrolled. UIImageView *separatorLine = [[UIImageView alloc] initWithFrame:CGRectMake(0.0f, cell.frame.size.height - 1.0f, cell.frame.size.width, 1.0f)]; separatorLine.image = [[UIImage imageNamed:@"grayDot"] stretchableImageWithLeftCapWidth:1 topCapHeight:0]; separatorLine.tag = 4; [cell.contentView addSubview:separatorLine]; [separatorLine release]; } // Setup default cell setttings. ... UIImageView *separatorLine = (UIImageView *)[cell viewWithTag:4]; separatorLine.hidden = NO; ... // In the cell I want to hide the line, I just hide it. seperatorLine.hidden = YES; ...
In viewDidLoad:
[code]self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
更多2
上一篇页面跳转动画设置方法
下一篇iphone
正则表达式使用(NSRegularExpression)
顶
0
相关文章推荐
- @GeneratedValue jap&hibernate生成字段策略
- Extjs的Requiers作用
- UITableViewCell使用NSTimer导致Cell的dealloc方法不被调用
- vector,list,deque容器的迭代器简单介绍
- iOS7中计算UILabel中字符串的高度
- openfire LDAP Guide
- 'UIAccelerometer' is deprecated
- .NET项目持续集成实践 - Jenkins
- Code Sign error: No matching provisioning profile found: Your build settings specify a provisioni.
- 【Java】优先队列PriorityQueue
- sublime Text2 2.0.2 build 2221 64位 破解(已测试)
- hql(Hibernate Query Language)
- EasyUi的DataGrid组件扩展,显示统计当前页信息
- 4.跟我学solr---SolrRequestHandler详解
- Codeforces Round #243 (Div. 1)——Sereja and Two Sequences
- Error in an XML file: aborting build
- IOS UITextView加上placeholder
- Guidelines for high quality lossy audio encoding
- FFmpeg and AAC Encoding Guide
- KeyValuePair C#