清除UITableView底部多余的分割线
来源:互联网 发布:淘宝上传新品宝贝描述 编辑:程序博客网 时间:2024/05/03 15:48
{
UIView *view = [UIView new];
view.backgroundColor = [UIColor clearColor];
[tableView setTableFooterView:view];
[view release];
}
- (void)viewDidLoad
{
[super viewDidLoad];
//设置tableView不能滚动
[self.tableView setScrollEnabled:NO];
//在此处调用一下就可以啦 :此处假设tableView的name叫:tableView
[self setExtraCellLineHidden:self.tableView];
}
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
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:
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- 清除UITableView底部多余的分割线
- 清除UITableView底部多余的分割线
- 清除UITableView底部多余的分割线
- 清除UITableView底部多余的分割线
- 清除UITableView底部多余的分割线
- 清除UITableView底部多余的分割线
- 清除UITableView底部多余的分割线
- 清除UITableView底部多余的分割线
- 清除UITableView底部多余的分割线
- 清除UITableView底部多余的分割线
- 清除UITableView底部多余的分割线
- 清除UITableView底部多余的分割线
- 清除UITableView底部多余的分割线
- iOS 清除UITableView底部多余的分割线
- UITableView 分割线设置 (去掉底部多余的分割线)
- 一句话去除UITableView底部多余行及分割线
- 一句话去除UITableView底部多余行及分割线
- 去除UITableView底部多余行及分割线
- 关于struts2的配置文件,namespace的使用
- android版本判断
- 解读 IIS日志里状态为200 0 64出现的原因
- hadoop 1.03 安装配置
- Path Sum II
- 清除UITableView底部多余的分割线
- JavaScript中 ==(等于) 与 === (恒等于) 的区别
- 解决IE6中A标签提交表单的办法
- Cocos2d-x笔记:清空CCUserDefault数据,获取时间(每日领取),子弹拖尾,字体
- 05-jbpm工作流的流转Transition
- Uninstall WinRAR with WindowsUninstaller.Org Removal Tips
- 文本数据导入HBASE
- poj 3026 Borg Maze
- IOS常用的定义