Search code examples
iosswifttableviewaccessory

UITableView left margin checkmark buttons - Swift


I'm trying to add check marks to my UItableview cells. I want to checkmarks to display like circle buttons on the left margin like this image:

enter image description here

I am unable to get the checkmarks in the left margin with my code and instead I keep getting checkmarks on the right that display only when tapped. Here is my current code:

override func tableView(tableView: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath) {
if let cell = tableView.cellForRowAtIndexPath(indexPath) {
    cell.accessoryType = .None
}
}
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
if let cell = tableView.cellForRowAtIndexPath(indexPath) {
    cell.accessoryType = .Checkmark

}
}

Any idea on how i can get the checkmarks to display on the left like the image?


Solution

  • I've made for you whole sample application for this.

    just try this. And this is what it looks like. enter image description here