ios - 如何删除 UITableView 中的单元格分隔符?

标签 ios swift uitableview

我想删除 UITableView 中的单元格分隔符。这是我的模拟器目前的样子:

enter image description here

我在 View Controller 的 .swift 文件的 viewDidLoad: 方法中实现了以下代码行:

self.tableView.separatorStyle = UITableViewCellSeparatorStyle.None

虽然这似乎不起作用。

如何去除电池隔板?

这是我的 cellForRowAtIndexPath: 代码:

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cellIdentifier = "Cell"
        let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier, forIndexPath: indexPath) as! RestaurantsTableViewCell

        // Configure the cell...
        cell.nameLabel.text = restaurants[indexPath.row].name
        cell.typeLabel.text = restaurants[indexPath.row].type
        cell.mainImageView.image = UIImage(named: restaurants[indexPath.row].image)

    return cell

}

最佳答案

  1. 检查您的单元格布局,尤其是顶部和底部约束。 enter image description here
  2. 检查单元格的内容 View 。您是否将 clips to bounds 设置为 true? enter image description here enter image description here

以上所有内容都应在代码和 IB 中进行检查。

关于ios - 如何删除 UITableView 中的单元格分隔符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34601934/

相关文章:

ios - 在 SwiftUI 中重新创建 twitter 的复制到剪贴板动画

ios - iPhone X 主页指示灯

swift - 使用RxSwift处理keyboardWillHide

ios - Swift canEditRowAtIndexPath 在 UIPageViewController EZSwipeViewController 中不起作用

iOS - 如何查看 TableView 单元格上的 "Swipe To Delete"操作?

ios - 通过隐藏标签栏自定义 UITabBarController。馊主意 ?

ios - UIViewController 和 UINavigationController 之间的区别?

ios - 在 iOS 中,使用 Swift,你如何获得 iPhone 启动的时间?

ios - 直接在应用程序 Swift 中打开 Epub

ios - Swift,自定义 UITableViewCell 和 UIImageView。需要将单元格调整为图像高度