Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/102.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 具有自定义节和单元格的TableView_Ios_Objective C_Uitableview_Tableview - Fatal编程技术网

Ios 具有自定义节和单元格的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

我有这样的tableView,我的问题是在每个部分的底部都有可见的分隔符。我怎样才能删除它?我需要在部分中间使用它,而不是在底部

此外,我需要相同的空间之间的部分。我明白了。我的代码

- (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];
}