tableView commitEditingStyle 时,imageView 高度溢出?

While commitEditingStyle in tableView, imageView height goes big overflow?

我发现在tableView中向左滑动commitEditingStyle时,包括imageView有点向下(溢出),我的错在哪里?我已经添加了一些关于我所做的事情的信息。

在每一侧​​使用自动布局 0 Superview:

viewDidLoad 中像这样设置 tableView rowHeight:

override func viewDidLoad() {
    super.viewDidLoad()

    // deleting top tableView spacing..
    tableView.contentInset = UIEdgeInsetsZero
    self.automaticallyAdjustsScrollViewInsets = false

    // set rowHeight
    tableView.rowHeight = (self.view.frame.height - self.navigationController!.navigationBar.frame.size.height - 20) / 4

    tableView.delegate = self
    tableView.dataSource = self

}

这是我的 commitEditingStyle 函数 tableView:

func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {

    if editingStyle == .Delete {
        let city = cities[indexPath.row]
        ad.managedObjectContext.deleteObject(city)
        do {
            try ad.managedObjectContext.save()
        }
        catch {
            fatalError("Error deleting item!")
        }

        fetchAndSetResults()

    } else if editingStyle == .Insert {
        // ..
    }
}

如果您使用 "Aspect Fill" 模式,只需将 "Clip Subviews" 添加到单元格中的 ImageView。

我添加这个解决了这个问题,

cell.recipeImg.layer.masksToBounds = true

cellForRowAtIndexPath: 方法中添加 imageView。