tobeiosdev tobeiosdev - 8 months ago 33
Swift Question

While commitEditingStyle in tableView, imageView height goes big overflow?

I find that while swipe Left for commitEditingStyle in tableView, including imageView goes a bit down (overflow), where is my fault? I have added some informations about what I did.

Using auto layouts 0 to each side Superview:

enter image description here

Setting tableView rowHeight like this in viewDidLoad:

override func 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


Here's my commitEditingStyle func for tableView:

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

if editingStyle == .Delete {
let city = cities[indexPath.row]
do {
catch {
fatalError("Error deleting item!")


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

enter image description here


I solved this problem adding this,

cell.recipeImg.layer.masksToBounds = true

in cellForRowAtIndexPath: method while imageView adding.