Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.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 选定单元格时UITableView分隔符颜色发生变化_Ios_Swift_Uitableview - Fatal编程技术网

Ios 选定单元格时UITableView分隔符颜色发生变化

Ios 选定单元格时UITableView分隔符颜色发生变化,ios,swift,uitableview,Ios,Swift,Uitableview,我创建了UITableView,但分隔符有问题。我对其进行了自定义,使其显示为灰色且无插图: self.tableView.separatorInset = .zero self.tableView.separatorColor = AppColors.separatorColor 我还尝试了一个图像: self.tableView.separatorInset = .zero tableView.separatorStyle = UITableViewCellSeparatorStyle.s

我创建了UITableView,但分隔符有问题。我对其进行了自定义,使其显示为灰色且无插图:

self.tableView.separatorInset = .zero
self.tableView.separatorColor = AppColors.separatorColor
我还尝试了一个图像:

self.tableView.separatorInset = .zero
tableView.separatorStyle = UITableViewCellSeparatorStyle.singleLine
tableView.separatorColor = UIColor(patternImage: #imageLiteral(resourceName: "thin_divider"))
问题:选择行时,分隔符变为白色。我玩了didSelectRowAtdidSelectRowAtdidheighlightrowat但没什么可做的,当单元格被选中时,它会保持白色。请参见下面的示例(此示例中选择了最后一个单元格)


cellforrowatinexpath
方法中尝试此代码行

[cell setSelectionStyle: UITableViewCellSelectionStyleNone];
这将设置“无”作为选择样式(此属性的默认值为
UITableViewCellSelectionStyleBlue

对于单元格突出显示部分,请使用
didSelectRowAtIndexPath
中的以下代码:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    [cell setHighlighted: NO];
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
} 

希望这有帮助。

您确定这是分隔符,而不是tableview和下一个视图之间的1像素间距吗?因为在您的图像上,它只显示在最后一个单元格之后,而不是每个单元格之后。@smeshko是的,当然,因为在图像上我选择了最后一个单元格,但是如果我选择了任何其他单元格,分隔符也会变为white@Mrunal是的,谢谢,它解决了问题,但当按下时,不再突出显示单元格