【问题标题】:UITableView separator line disappears when selecting cells in iOS7在iOS7中选择单元格时UITableView分隔线消失
【发布时间】:2013-10-13 07:07:15
【问题描述】:

在我的 tableView 中,我在单元格之间设置了分隔线。我允许选择多个单元格。这是我设置选定单元格背景颜色的代码:

UIView *cellBackgroundColorView = [[UIView alloc] initWithFrame:cell.frame];
[cellBackgroundColorView setBackgroundColor:[UIColor darkGray]];
[cell setSelectedBackgroundView:cellBackgroundColorView];

问题是如果两个相邻的单元格被选中,在iOS7中它们之间没有分隔线,而在iOS6中(如预期的那样)。

我什至尝试将cellBackgroundColorView 的帧高度设置为cell.frame - 1.0,但这也不起作用。

有什么想法吗?

【问题讨论】:

    标签: uitableview ios7


    【解决方案1】:

    我还没有深入了解它(乍一看,这似乎是一个 iOS 7 错误..),但我找到了解决方法。在 tableView:didSelectRowAtIndexPath 中,如果您同时发送下面的两条消息,则问题会在视觉上得到解决(可能会降低性能)。

    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    [tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
    

    为此(对我而言),deselectRowAtIndexPath:animated: 必须包含动画:YES。用于 reloadRowsAtIndexPaths:withRowAnimation: 的动画无关紧要。

    【讨论】:

    • 我正在寻找这个确切的问题,但这对我不起作用,单元格只是取消选择并且不保留我为所选视图设置的背景颜色。有什么我想念的吗?
    • 我的回答仅与点击单元格后分隔线消失有关。我假设问题的背景颜色部分只是支持信息。如果您在使用背景颜色时遇到问题,以下解决方案之一可能更适合您。
    • 您在 didSelectRowAtIndexPath 中调用 deselectRowAtIndexPath,这不会自动取消选择您选择的任何行吗?我错过了什么吗?
    • @Mark,如果我尝试使用你的代码,它会导致我选择的单元格最终未被选中,这违背了目的。我想选择多个(相邻)单元格(突出显示背景)并且分隔符可见。
    • 它适用于隐藏在单元格内的UIDatePicker tableView.beginUpdates() // 1 tableView.endUpdates() tableView.deselectRowAtIndexPath(indexPath, animated: true) // 2 tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: .None) //3 1) 更新单元格以通过动画更改其高度 2) 我省略了这一行,因为我有单元格选择样式 none 3) @ 987654325@更新中断reloadRowsAtIndexPaths,所以我在这里使用了行动画none
    【解决方案2】:

    您也可以尝试将分隔插图设置为 0。我这样做了,它解决了问题,但代价是您失去了插图的美观。

    【讨论】:

      【解决方案3】:

      单个单元格选择也存在此问题。

      另一种解决方案是重新加载表格视图,选择后取消选择:

      self.selectedIndex = inIndexPath.row;
      [inTableView reloadData];
      [inTableView selectRowAtIndexPath:inIndexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
      [inTableView deselectRowAtIndexPath:inIndexPath animated:YES];
      

      这消除了我在 Mark 的解决方案中看到的一个微妙的图形选择故障。

      【讨论】:

        【解决方案4】:

        从 iOS 7.0.3 开始,这似乎仍然是一个问题,但我已经通过一种简单的方法来伪造分隔符来解决它。

        首先将UITableView 的分隔符样式设置为UITableViewCellSeparatorStyleNone。然后,您可以使用自定义 UITableViewCell 子类来伪造选中和未选中状态的单元格之间的分隔符:

        @implementation MyTableViewCellSubclass
        
        - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
        {
            self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
            if (self) {
        
                CGRect frame = self.bounds;
                frame.origin.y = frame.size.height - 1.f;
                frame.size.height = 1.f;
        
                // Selected background view
                //
                UIView * separatorView = [[UIView alloc] initWithFrame:frame];
                separatorView.backgroundColor = [UIColor darkGrayColor];
                separatorView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleTopMargin;
        
                UIView * selectedView = [[UIView alloc] initWithFrame:self.bounds];
                selectedView.backgroundColor = [UIColor lightGrayColor];
                [selectedView addSubview:separatorView];
        
                self.selectedBackgroundView = selectedView;
        
                // Add separator view to content view for unselected state
                //
                UIView * separatorView2 = [[UIView alloc] initWithFrame:frame];
                separatorView2.backgroundColor = [UIColor darkGrayColor];
                separatorView2.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleTopMargin;
        
                [self.contentView addSubview:separatorView2];
        
        
            }
            return self;
        }
        
        
        @end
        

        【讨论】:

        • 这项工作非常适合我的目的。谢谢你,好心的先生。
        • 单元格上方的行仍然丢失。 separatorView2 也不覆盖accessorView 的区域。
        【解决方案5】:

        无论如何,此解决方案不会帮助任何不在其单元格上使用 backgroundView 的人:

        - (void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
            {
                [cell setBackgroundColor:[UIColor grayColor]];
            }
        

        这样烦人的视觉效果会大大减少,而无需重新加载表格。 当然,您可以将grayColor 更改为任何有助于您改善案例结果的东西

        【讨论】:

          【解决方案6】:

          使用这个:

          - (BOOL)tableView:(UITableView *)tableView shouldHighlightRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = (UITableViewCell *)[tableView cellForRowAtIndexPath:indexPath]; UIView *selectionColor = [[UIView alloc] init]; selectionColor.backgroundColor = [UIColor clearColor]; cell.selectedBackgroundView = selectionColor; //71 UIView* separatorLineView = [[UIView alloc] initWithFrame:CGRectMake(0, 71, 320, 2)];//根据需要改变大小,其中-71-y坐标,320-重量,2-高度 // separatorLineView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"divider_goriz.png"]];//这里也可以放图片 separatorLineView.backgroundColor = [UIColor redColor]; [cell.selectedBackgroundView addSubview:separatorLineView]; 返回是; }

          【讨论】:

            【解决方案7】:

            将此代码添加到 indexpath

            行的单元格中
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            cell.textLabel.backgroundColor = [UIColor clearColor];
            

            【讨论】:

            • 这对我来说是解决办法。
            • 这是正确答案。 @Mark 的回答是完全错误的。它取消选择应该保持选中的内容,这没有任何意义。
            • 我很困惑! cell.selectionStyle = UITableViewCellSelectionStyleNone; 使选择单元格成为不可能!这如何解决手头的问题?
            • 谢谢!!为我工作。
            • 重要的是要注意设置 selectionStyle= UITableViewCellSelectionStyleNone 会阻止 UITableViewController.clearsSelectionOnViewWillAppear=YES 按预期工作。当在导航控制器中弹出时,VC 不会在 viewWillAppear 中呈现单元格的取消选择动画。
            【解决方案8】:

            我解决了这个问题(hackishly),不仅重新加载选定的单元格,还重新加载它正上方的单元格。上述其他解决方案都不适合我。

                NSIndexPath *indexPathOfCellAbove = [NSIndexPath indexPathForRow:(indexPath.row - 1) inSection:indexPath.section];
            
                if (indexPath.row > 0)
                    [self.tableView reloadRowsAtIndexPaths:@[indexPathOfCellAbove, indexPath] withRowAnimation:UITableViewRowAnimationNone];
                else
                    [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
            

            【讨论】:

              【解决方案9】:

              我做的是这样的:

              1. 在单元格的内容视图下添加一个新的子视图。
              2. 将单元格中的内容连接为 selectedBackgroundView。
              3. 添加新选定背景视图的子视图。将其设置为从左侧开始 16 像素并覆盖其余宽度,高 1 像素,从顶部向下 1 像素,背景颜色为 90% 白色。

              在我的例子中,我不希望我的行在被选中时被遮蔽,所以我让选中的背景视图保持清晰,但你可以将其设置为任何你喜欢的颜色。

              另外,我没有使用自动布局,所以只需适当地设置我的尺寸。我认为使用自动布局您必须设置适当的约束。

              对我来说,这完全解决了问题(尽管我同意这确实是 ios 7 中的一个错误)。

              【讨论】:

                【解决方案10】:

                @samvermette 的answer 为我解决了这个问题,但我必须先取消选择选定的行。

                - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath  {
                
                    //Deselect Row
                    [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
                
                    // fix for separators bug in iOS 7
                    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
                    self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine; }
                

                【讨论】:

                • 如果您的表格启用了多项选择选项(即当您需要使用复选标记附件视图时),则该行为与您的解决方案冲突。问题是选择时调用的 deselectRowAtIndexPath:animated: 方法。还有其他方法吗?
                • 我一个人绝对不会到那里。很好的解决方案。
                【解决方案11】:

                - cellForRowAtIndexPath

                Create two separator views (sv1, sv2)
                
                [cell addsubview:sv1];
                [cell.selectedBackgroundView addsubview:sv2];
                

                - didSelectRowAtIndexPath

                [tableView deselectRowAtIndexPath:indexPath animated:NO];
                

                【讨论】:

                  【解决方案12】:

                  如果您让 iOS 应用自己的默认选定单元格样式,就会发生这种情况。到目前为止,我发现的最佳解决方法是覆盖选定的属性实现:

                  在您的单元子类实现中:

                      @synthesize selected = _selected;
                  

                  在初始化方法中:

                      // problem actually is caused when you set following 
                      // to UITableViewCellSelectionStyleDefault, so:
                  
                      [self setSelectionStyle:UITableViewCellSelectionStyleNone]; 
                  

                  覆盖方法:

                      - (BOOL)selected 
                      {
                          return _selected;
                      }
                      - (void)setSelected:(BOOL)selected animated:(BOOL)animated 
                      {
                          _selected = selected
                          if (selected) {
                  
                              // apply your own selected style
                  
                          }
                          else {
                  
                              // apply your own deselected style
                  
                          }
                      }
                  

                  【讨论】:

                  • 太棒了!这在 iOS 9 中完美运行。当您简单地更改单元格背景颜色而不是添加选定视图时,它还保持顶部和底部的分隔线。好东西!
                  • 其实我有一个需要使用的透明颜色,所以我添加了一个 backgroundView,然后为它的 backgroundColor 设置动画。分隔符保持可见!!!
                  【解决方案13】:

                  这个简单的调用在 iOS 8 上为我完成了。

                  - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
                      // ....
                      [tableView deselectRowAtIndexPath:indexPath animated:YES]
                  
                      // ....
                  }
                  

                  【讨论】:

                  • 为我工作。单元格的选择样式为无,表格 - 单选
                  • 这对我有用(选择样式无,单选)——只要我在 beginUpdates / endUpdates 块内(或之前)调用它。
                  【解决方案14】:

                  这里的解决方案对我没有帮助。在大多数情况下,建议删除选择,但我希望单元格保持其选定状态。所以想法是禁用默认分隔线并使用您自己的分隔线。我试过这个,但我遇到了问题(你可以阅读更多关于这个here)。主要问题是在accessoryView 区域中画线。它只适用于 iOS 8,但我还需要适用于 iOS 7 的解决方案。

                  我的要求是:

                  • 应保留选择
                  • 行不应消失(尤其是在单元格被选中的情况下)
                  • 所选单元格上方的分隔线也不应该消失

                  尤其是第三点出现了问题,因为iOS 使用了一种抗锯齿效果来将UITableViewCell 与下一个交叉。我发现这只发生在 iPad 上。它在每个方向(当前选定的单元格,上方的单元格)上具有大约一个点的大小,因此即使在单元格本身上绘制了一条线(而不是默认使用的),单元格上的一条线也会消失。这条线是在上面的单元格上还是在选定的单元格上没有区别。这种特殊的渲染效果隐藏了我的线条。

                  解决方案如下所示:

                  1. 使用backgroundView 绘制两条线:一条在顶部(iPad 的 y 方向 +1 点,iPhone 的 y 方向 0 点)和底部的一条。所以它永远不会被选择效果覆盖。
                  2. 创建的背景视图只能用于选定状态 (cell.selectedBackgroundView = selectedBackground)。为其他单元格启用了默认分隔线。

                  我有一个 C# 代码发布的工作示例 here 尽管您必须根据您的需要对其进行调整。现在我的选择问题已经解决了!

                  【讨论】:

                    【解决方案15】:

                    在我的情况下,我正在为一行设置动画,所以我只需要像这样放置一些:

                    -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
                    
                    [tableView beginUpdates];
                    [tableView deselectRowAtIndexPath:indexPath animated:NO]; 
                    //if you are doing any animation you have deselect the row here inside. 
                    [tableView endUpdates];
                    } 
                    

                    【讨论】:

                    • 这仍然适用于 iOS 9,动画单元格高度我的 tableview 行之一消失了。这解决了它。我从动画块中的 didSelectRowAtIndexPath 中调用了它。
                    • 当我省略 begin- 和 endUpdates 时,它也可以工作(在 iOS9 中)。在这两种情况下,我都松开了取消选择动画......有什么想法吗?
                    • 虽然这可行,但您必须小心 beginUpdates/endUpdates 块,确保您的数据源中没有任何变化,否则您会遇到运行时异常。
                    【解决方案16】:

                    对我来说,它发生在我以编程方式设置时:

                    cell.selectionStyle = UITableViewCellSelectionStyleNone;
                    

                    当我在情节提要中设置此属性时,它工作正常。

                    【讨论】:

                    • 这也是我遇到问题的地方。
                    【解决方案17】:

                    太刺激了,我解决了这个问题。 在自定义单元格中添加以下方法调用,并设置颜色分隔符和框架。我将隐藏单元格分隔符,然后在 superview 中自定义负载分隔符上的视图。解决了这个问题就选择了冲击分隔格啦

                    @interface MyCustomTableViewCell(){
                       UIView *customSeparatorView;
                       CGFloat separatorHight;
                    }
                    @property (nonatomic,weak)UIView *originSeparatorView;
                    @end
                    
                    -(void)setSeparatorWithInset:(UIEdgeInsets)insets{
                    
                    if (customSeparatorView) {
                        customSeparatorView.frame = CGRectMake(insets.left, insets.top,self.width - insets.left - insets.right, self.originSeparatorView.height-insets.bottom - insets.top);
                        self.originSeparatorView.hidden = YES;
                        self.originSeparatorView.alpha = 0;
                    }else{
                        for (int i = ([self.contentView.superview.subviews count] - 1); i >= 0; i--) {
                            UIView *subView = self.contentView.superview.subviews[i];
                            if ([NSStringFromClass(subView.class) hasSuffix:@"SeparatorView"]) {
                                self.originSeparatorView = subView;
                                subView.hidden = YES;
                                subView.alpha = 0;
                                subView.frame = CGRectMake(insets.left, insets.top,self.width - insets.left - insets.right, subView.height-insets.bottom - insets.top);
                    
                                customSeparatorView = [[subView superview] viewWithTag:separatorViewTag];
                                if (!customSeparatorView) {
                                    customSeparatorView = [[UIView alloc] initWithFrame:subView.frame];
                    
                                    customSeparatorView.tag = separatorViewTag;
                                    [[subView superview] addSubview:customSeparatorView];
                                    customSeparatorView.backgroundColor = [subView backgroundColor];
                                }
                                [[subView superview] bringSubviewToFront:customSeparatorView];
                                break;
                            }
                        }
                      }
                    }
                    
                    
                    -(void)setSeparatorColorWithColor:(UIColor *)sepColor{
                    if (customSeparatorView) {
                        customSeparatorView.backgroundColor = sepColor;
                    
                        self.originSeparatorView.hidden = YES;
                        self.originSeparatorView.alpha = 0;
                    }else {
                        for (int i = ([self.contentView.superview.subviews count] - 1); i >= 0; i--) {
                            UIView *subView = self.contentView.superview.subviews[i];
                            if ([NSStringFromClass(subView.class) hasSuffix:@"SeparatorView"]) {
                               self.originSeparatorView = subView;
                    
                                if (sepColor) {
                                    subView.hidden = YES;
                                    subView.alpha = 0;
                                    subView.backgroundColor = sepColor;
                    
                                    customSeparatorView = [[subView superview] viewWithTag:separatorViewTag];
                                    if (!customSeparatorView) {
                                        customSeparatorView = [[UIView alloc] initWithFrame:subView.frame];
                    
                                        customSeparatorView.tag = separatorViewTag;
                                        [[subView superview] addSubview:customSeparatorView];
                                        customSeparatorView.backgroundColor = [subView backgroundColor];
                                    }
                                    [[subView superview] bringSubviewToFront:customSeparatorView];
                                }
                                break;
                            }
                        }
                      }
                    }
                    
                     -(void)layoutSubviews{
                        [super layoutSubviews];
                        [self setSeparatorWithInset:UIEdgeInsetsMake(0, 0, 0, 0)];
                        [self setSeparatorColorWithColor:[UIColor colorWithRed:31/255.0 green:32/255.0f blue:35/255.0 alpha:0.2]];
                     }
                    

                    【讨论】:

                      【解决方案18】:

                      对于那些在 Swift 中寻找解决方案的人来说,这为我解决了这个问题。在您的cellForRowAtIndexPath 方法中,调用dequeueReusableCellWithIdentifier 后,您只需将单元格selectionStyle 设置为.None

                      代码如下:

                          override func tableView(tableView: UITableView?,  cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
                          let cell:TextTableViewCell = tableView!.dequeueReusableCellWithIdentifier("textCell", forIndexPath: indexPath) as! TextTableViewCell
                      
                          cell.selectionStyle = .None //  This fixes the disappearing border line issue
                      

                      【讨论】:

                      • 使用这意味着选择单元格时不会发生任何事情(或者似乎延迟突出显示背景)。
                      【解决方案19】:

                      为我解决问题的是在 beginUpdates 和 endUpdates 之后重新加载数据:

                          private func animateCellHeighChangeForTableView(tableView: UITableView, withDuration duration: Double) {
                              UIView.animateWithDuration(duration) { () -> Void in
                                 tableView.beginUpdates();
                                 tableView.endUpdates();
                                 tableView.reloadData();
                              }
                          }
                      

                      【讨论】:

                        【解决方案20】:

                        当我以编程方式将单元格的选择样式设置为无,然后以编程方式选择表格单元格时,我遇到了这个问题。

                            func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
                            let cell: UITableViewCell!
                            if tableView == self.jobLevelTableView {
                                let cell = tableView.dequeueReusableCell(withIdentifier: "cellIdentifier", for: indexPath) as! CheckboxCell
                        
                                // for testing purposes
                                let checked = true
                        
                                // I used M13Checkbox here, in case anybody was wondering
                                cell.checkbox.setCheckState(checked ? .checked : .unchecked, animated: false) 
                        
                                if checked {
                                    tableView.selectRow(at: indexPath, animated: true, scrollPosition: .none)
                                }
                        
                                // CULPRIT
                                cell.selectionStyle = .none
                                return cell
                            }
                        
                            cell = UITableViewCell()
                            return cell
                        }
                        

                        当我在情节提要上设置选择样式(并删除等效代码)时,问题就消失了!

                        【讨论】:

                          【解决方案21】:

                          将它粘贴到您的 UITableViewCell 类中。

                          override func layoutSubviews() {
                              super.layoutSubviews()
                          
                              subviews.forEach { (view) in
                                  if type(of: view).description() == "_UITableViewCellSeparatorView" {
                                      view.alpha = 1.0
                                  }
                              }
                          }
                          

                          【讨论】:

                            【解决方案22】:

                            我需要以下内容:

                            "当用户选择行时,选择背景颜色为 透明/白色/不管你怎么称呼它,分隔线不 消失”

                            我也在寻找解决以下问题的方法:

                            “当我在表格(普通表格)中选择一行时,我有选择 颜色为灰色,如果我将 cell.selectionStyle 设置为 none -> 分隔符 细胞之间消失了。”

                            Xcode - 9.2 版本

                            找到以下解决方案:

                            1. 在'tableView (....cellForRowAT...)' let colorView = UIView(frame: CGRect(x: 0.0, y: 3.0, width: cell.frame.width, height: cell.frame.height - 1.0)) colorView.backgroundColor = UIColor.white UITableViewCellClass.appearance().selectedBackgroundView = colorView

                            UITableViewCellClass - 是你的原型单元类 可以将选择颜色更改为白色

                            1. 在“tableView (...didSelectRowAt)”中 cell.selectionStyle = .none

                            2. 在 UITableViewCellClass(你的原型单元类)中

                              覆盖 func layoutSubviews() { super.layoutSubviews()

                              subviews.forEach { (view) in
                                  if type(of: view).description() == "_UITableViewCellSeparatorView" {
                                      view.alpha = 1.0
                                  }
                              }
                              

                              }

                            它允许使用复选标记保留选定的行,并且所有分隔符都在适当的位置。

                            【讨论】:

                              【解决方案23】:

                              我在IOS 13遇到这个问题,是这样解决的:

                              1. 在 tableView 单元故事板或 xib 文件中选择无选择

                              2. 在单元格覆盖函数的swift文件中:

                                override func setHighlighted(_ highlighted: Bool, animated: Bool) {
                                
                                    super.setHighlighted(highlighted, animated: animated)
                                
                                    if highlighted {
                                        contentView.backgroundColor = .lightGray
                                    } else {
                                        contentView.backgroundColor = .clear
                                    }
                                }
                                

                              我想像以前的 IOS 版本一样获得常规选择的效果,但是如果您想获得其他东西,请使用您的颜色自定义功能。

                              【讨论】:

                                【解决方案24】:

                                在 iOS 14 中,Apple 终于减轻了这种痛苦。

                                如果你想...

                                • ...能够选择行(例如在编辑模式下)
                                • ...防止默认的灰色或蓝色单元格突出显示颜色
                                • ...保留默认的系统分隔符视图

                                ...这将对您有所帮助。在您的 UITableViewCell 子类中,将其放入初始化程序中:

                                override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
                                    super.init(style: style, reuseIdentifier: reuseIdentifier)
                                    
                                    // Prevent cell highlighting while preserving selectability and separator views
                                    if #available(iOS 14.0, *) {
                                        var backgroundConfig = UIBackgroundConfiguration.listPlainCell()
                                        backgroundConfig.backgroundColor = .clear
                                        backgroundConfiguration = backgroundConfig
                                    } else {
                                        selectedBackgroundView = {
                                            let bgView = UIView(frame: .zero)
                                            bgView.translatesAutoresizingMaskIntoConstraints = false
                                            bgView.backgroundColor = .clear
                                            return bgView
                                        }()
                                    }
                                }
                                

                                如果您只针对 iOS 14+,您可以省略 else 块,您就完成了。如果您还针对 iOS 13 及更低版本,您还需要覆盖 layoutSubviews 以防止分隔符视图消失(感谢此评论:https://stackoverflow.com/a/47573308/171933)。这可以解决问题(也在您的 UITableViewCell 子类中):

                                override func layoutSubviews() {
                                    super.layoutSubviews()
                                
                                    if #available(iOS 14.0, *) {
                                        // no op
                                    } else {
                                        // Setting a custom selectedBackgroundView causes the system to hide the
                                        // separatorView. If we want to have the separator, we need to show it again.
                                        subviews.forEach { view in
                                            if type(of: view).description() == "_UITableViewCellSeparatorView" {
                                                view.alpha = 1.0
                                            }
                                        }
                                    }
                                }
                                

                                享受吧。

                                【讨论】:

                                • 天哪,多年来我不得不采取的变通办法才能得到不好的结果。谢谢你!!!
                                • @AndrewEdwards 是的,我们必须跳过多少圈才能让这样的东西正常工作,这太荒谬了。应该不会这么难。
                                猜你喜欢
                                • 1970-01-01
                                • 2023-04-10
                                • 1970-01-01
                                • 1970-01-01
                                • 1970-01-01
                                • 1970-01-01
                                • 1970-01-01
                                • 1970-01-01
                                • 2013-09-26
                                相关资源
                                最近更新 更多