Search code examples
ios7swiftios8xcode6-beta7

Custom UITableViewCell editing mode not working


i'm currently working on an app for iOS 7 and iOS 8 with Xcode 6 build 7 coding with Swift. In one of the view controllers I got a tableview with custom cells, the thing is, that when I set the tableview property editing to "true", nothing occurs, I don't see the delete button, but if I use a default cell instead of mine it works.

I've used all the necessary methods

func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
    return true
}

func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
    if (editingStyle == UITableViewCellEditingStyle.Delete) {
        // handle delete (by removing the data from your array and updating the tableview)
    }
}

func tableView(tableView: UITableView, editingStyleForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCellEditingStyle {
    return .Delete
}

but nothing happens, anyone has had the same problem?

Thanks!!


Solution

  • Ok solved, after all the solution was in front of me all the time, the thing was that in the layoutSubviews method of the cells I was doing things, but I totally forgot to call the super.layoutSubviews, when I did this, everything worked perfect.