Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/116.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 Can';t在UITableView中选择后更改分隔符(自定义UIView)颜色_Ios_Iphone_Uitableview - Fatal编程技术网

Ios Can';t在UITableView中选择后更改分隔符(自定义UIView)颜色

Ios Can';t在UITableView中选择后更改分隔符(自定义UIView)颜色,ios,iphone,uitableview,Ios,Iphone,Uitableview,我在点击后改变单元格颜色,我也在改变单元格底部的小自定义分隔符。但是,当我调用deselerowatinexpath时,分隔符颜色将恢复为忽略更改之前的颜色。为什么会发生这种情况,我如何完成这个简单的任务? 这是我的密码: [tableView deselectRowAtIndexPath:indexPath animated:NO]; UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; UIView *sep

我在点击后改变单元格颜色,我也在改变单元格底部的小自定义分隔符。但是,当我调用
deselerowatinexpath
时,分隔符颜色将恢复为忽略更改之前的颜色。为什么会发生这种情况,我如何完成这个简单的任务? 这是我的密码:

[tableView deselectRowAtIndexPath:indexPath animated:NO];
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
UIView *separator = [cell viewWithTag:SEPARATOR];
separator.backgroundColor = _colorOrangeSelected;
以下是一个解决方案:

  • UIImageView
    拖动到单元格中,并将其作为分隔符。使用两个不同的图像设置
    图像
    高光图像
选中单元格后,自定义单元格将自动刷新子视图状态,但您必须准备两个图像。

以下是解决方案:

  • UIImageView
    拖动到单元格中,并将其作为分隔符。使用两个不同的图像设置
    图像
    高光图像
选中单元格后,自定义单元格将自动刷新子视图状态,但您必须准备两个图像。

以下是解决方案:

  • UIImageView
    拖动到单元格中,并将其作为分隔符。使用两个不同的图像设置
    图像
    高光图像
选中单元格后,自定义单元格将自动刷新子视图状态,但您必须准备两个图像。

以下是解决方案:

  • UIImageView
    拖动到单元格中,并将其作为分隔符。使用两个不同的图像设置
    图像
    高光图像

选中单元格后,自定义单元格将自动刷新子视图状态,但您必须准备两张图像。

UIView不能使用highlightedColor。 您可以尝试以下解决方案: 1.使用可设置highlightedColor或highlightedImage的UIButton或UIImageView 2.使用drawRect:

- (void)drawRect:(CGRect)rect {
    [super drawRect:rect];
    if (self.cellDevideLineColor != nil) {
        CGContextRef context = UIGraphicsGetCurrentContext();

        [self.cellDevideLineColor set];
        CGContextSetLineWidth(context, kCellLineHeight);

        CGContextMoveToPoint(context, 0, rect.size.height);
        CGContextAddLineToPoint(context, self.width, rect.size.height);
        CGContextStrokePath(context);
    }
}

UIView不能具有highlightedColor。 您可以尝试以下解决方案: 1.使用可设置highlightedColor或highlightedImage的UIButton或UIImageView 2.使用drawRect:

- (void)drawRect:(CGRect)rect {
    [super drawRect:rect];
    if (self.cellDevideLineColor != nil) {
        CGContextRef context = UIGraphicsGetCurrentContext();

        [self.cellDevideLineColor set];
        CGContextSetLineWidth(context, kCellLineHeight);

        CGContextMoveToPoint(context, 0, rect.size.height);
        CGContextAddLineToPoint(context, self.width, rect.size.height);
        CGContextStrokePath(context);
    }
}

UIView不能具有highlightedColor。 您可以尝试以下解决方案: 1.使用可设置highlightedColor或highlightedImage的UIButton或UIImageView 2.使用drawRect:

- (void)drawRect:(CGRect)rect {
    [super drawRect:rect];
    if (self.cellDevideLineColor != nil) {
        CGContextRef context = UIGraphicsGetCurrentContext();

        [self.cellDevideLineColor set];
        CGContextSetLineWidth(context, kCellLineHeight);

        CGContextMoveToPoint(context, 0, rect.size.height);
        CGContextAddLineToPoint(context, self.width, rect.size.height);
        CGContextStrokePath(context);
    }
}

UIView不能具有highlightedColor。 您可以尝试以下解决方案: 1.使用可设置highlightedColor或highlightedImage的UIButton或UIImageView 2.使用drawRect:

- (void)drawRect:(CGRect)rect {
    [super drawRect:rect];
    if (self.cellDevideLineColor != nil) {
        CGContextRef context = UIGraphicsGetCurrentContext();

        [self.cellDevideLineColor set];
        CGContextSetLineWidth(context, kCellLineHeight);

        CGContextMoveToPoint(context, 0, rect.size.height);
        CGContextAddLineToPoint(context, self.width, rect.size.height);
        CGContextStrokePath(context);
    }
}

我通过为我的单元格子类化
UITableViewCell
,并重写
setSelected
setHighlighted
方法,解决了这个问题。我猜本机实现只是以一种奇怪的方式处理子视图和它们的背景,忽略了它们的最新状态

我通过为我的单元格子类化
UITableViewCell
并重写
setSelected
setHighlighted
方法解决了这个问题。我猜本机实现只是以一种奇怪的方式处理子视图和它们的背景,忽略了它们的最新状态

我通过为我的单元格子类化
UITableViewCell
并重写
setSelected
setHighlighted
方法解决了这个问题。我猜本机实现只是以一种奇怪的方式处理子视图和它们的背景,忽略了它们的最新状态

我通过为我的单元格子类化
UITableViewCell
并重写
setSelected
setHighlighted
方法解决了这个问题。我猜本机实现只是以一种奇怪的方式处理子视图和它们的背景,忽略了它们的最新状态