Ios 具有自定义节和单元格的TableView
我有这样的tableView,我的问题是在每个部分的底部都有可见的分隔符。我怎样才能删除它?我需要在部分中间使用它,而不是在底部 此外,我需要相同的空间之间的部分。我明白了。我的代码Ios 具有自定义节和单元格的TableView,ios,objective-c,uitableview,tableview,Ios,Objective C,Uitableview,Tableview,我有这样的tableView,我的问题是在每个部分的底部都有可见的分隔符。我怎样才能删除它?我需要在部分中间使用它,而不是在底部 此外,我需要相同的空间之间的部分。我明白了。我的代码 - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { if(section == 0) return 15; return 1.0; } - (CGFloat)tableVi
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
if(section == 0)
return 15;
return 1.0;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
return 14.0;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
return [[UIView alloc] initWithFrame:CGRectZero];
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
return [[UIView alloc] initWithFrame:CGRectZero];
}
替换这个
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
if(section == 0)
return 15;
return 1.0;
}
与
并删除这两种方法
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
在
viewDidLoad
[self.tableView setSeparatorColor:[UIColor clearColor]];
在cellforrowatinexpath:
中,您可以根据indexPath.row和indexPath.section值自定义分隔符视图,如
if(indexPath.row != self.yourArray.count-1)
{
UIImageView *line = [[UIImageView alloc] initWithFrame:CGRectMake(0, yourCellHeight -2, 320, 2)];
line.backgroundColor = [UIColor redColor];
[cell addSubview:line];
}
试试这个
[self.tableView setSeparatorColor:[UIColor clearColor]]代码>我想把它放在一些单元格中,但不是全部,然后对你想要的单元格试试这个cell.separatorInset=UIEdgeInsetsZero
一种可能的解决方案是将表视图的分隔符样式
设置为UITableViewCellSeparatorStyleNone
,并在所需单元格中添加自定义行。另一个选项是将cellForRow…
中每个单元格的分隔符设置为显示/隐藏分隔符的值。您能提供图像吗
if(indexPath.row != self.yourArray.count-1)
{
UIImageView *line = [[UIImageView alloc] initWithFrame:CGRectMake(0, yourCellHeight -2, 320, 2)];
line.backgroundColor = [UIColor redColor];
[cell addSubview:line];
}