首页 文章

如何删除iOS TableView分隔符

提问于
浏览
0

您好,感谢您的阅读 .
我试图删除这些分隔符一段时间,它是可怕的我不能删除它们 . 我在stackoverflow中尝试了很多答案,但没有人有帮助:/

这是问题所在:

UITableView Separator

我不能删除单元格之间的这些空格:s .

我试过了 :

  • 将背景颜色更改为与单元格相同的灰色,但不起作用

  • 检查单元格大小

  • 将separatorStyle设置为UITableViewCellSeparatorStyle.None

  • 用tableView返回好的高度(tableView:UITableView,heightForRowAtIndexPath indexPath:NSIndexPath) - > CGFloat

  • 在主故事板中禁用分隔符

...我真的不明白如何删除这些空白区域......

对不起我的英语不好,

谢谢

我加上这个 . 现在您可以检查我的设置:(并且您可以看到分隔符被禁用)

Settings uitableview

9 回答

  • 2

    你只需要在属性检查器中更改它:

    enter image description here

  • 0

    试试这个tableView方法:

    override func tableView(tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat 
    {
        return 0.00001
    }
    
  • 0

    试试这个希望对你有所帮助 .

    Objective C :

    -(CGFloat)tableView:(UITableView*)tableView heightForFooterInSection:(NSInteger)section
    {
        return 0.1f;
    }
    -(UIView*)tableView:(UITableView*)tableView viewForFooterInSection:(NSInteger)section
    {
        return [[UIView alloc] initWithFrame:CGRectZero] ;
    }
    

    Swift :

    override func tableView(tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
        return UIView(frame: CGRectZero)
      }
    
      override func tableView(tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
        return 0.1f
      }
    
  • 0

    同样设置 tableviewcell 分隔符 none 图像http://imgur.com/MbVA7pM

  • 0

    试试这个:

    func tableView(tableView: UITableView!, willDisplayCell cell: UITableViewCell!, forRowAtIndexPath indexPath: NSIndexPath!) {
        // Remove seperator inset
        if cell.respondsToSelector("setSeparatorInset:") {
            cell.separatorInset = UIEdgeInsetsZero
        }
    
        // Prevent the cell from inheriting the Table View's margin settings
        if cell.respondsToSelector("setPreservesSuperviewLayoutMargins:") {
            cell.preservesSuperviewLayoutMargins = false
        }
    
       // Explictly set your cell's layout margins
       if cell.respondsToSelector("setLayoutMargins:") {
           cell.layoutMargins = UIEdgeInsetsZero
       }
    }
    
  • 0

    在swift中隐藏表视图分隔符

    func tableView(tableView: UITableView!, willDisplayCell cell: UITableViewCell!, forRowAtIndexPath indexPath: NSIndexPath!) 
    {
       cell.backgroundColor = UIColor.clearColor()
    }
    
  • 0

    好的,对不起,问题出在我的代码上,所以你无法回答我......

    它在我的函数中:tableView(tableView:UITableView,cellForRowAtIndexPath indexPath:NSIndexPath) - > UITableViewCell

    在某个地方我想在我的手机上放一个边框,所以我写了:

    var layer: CALayer = cell.layer
            layer.borderColor = UIColor.rgbaColor(red: 288, green: 83, blue: 88, alpha: 1).CGColor
            layer.borderWidth = 2
    

    但是这个代码没有用,因为红色:288应该是红色的:188,所以我有一个白色边框而不是错误,我没有注意到......对不起,非常感谢你的帮助:)

  • 0

    只需将页脚视图设置为空视图:

    self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
    

    因此,对于空单元格,分隔符将消失(您仍然保留正常单元格的分隔符) .

  • 0

    在目标c

    [self.tableView setSeparatorColor:[UIColor myColor]];
    

    在斯威夫特

    tableView.separatorColor = UIColor.clear
    

相关问题