tobeiosdev tobeiosdev - 2 years ago 121
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

Answer Source

I solved this problem adding this,

cell.recipeImg.layer.masksToBounds = true

in cellForRowAtIndexPath: method while imageView adding.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download