-5

I would like to create an app with a list of TODO items. Each TODO should have a functional checkmark/checkbox on the left side of the cell. If I click on the right side of the TODO then I would like to show its details.

I have create a Table View. When I click on a cell I follow a segue to a UIViewController that shows the details of the cell.

I think displaying the checkmark may be possible by defining the cell's imageView. However, I can't make the imageView functional, i.e., clickable. Every time I click on it it simply shows the details.

Can you provide basic sample code to show how I can have both a segue to the details of the cell AND a checkmark that is clickable?

Thanks, Daniel

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Daniel
  • 3,758
  • 3
  • 22
  • 43
  • FYI: don't expect any answers here, since you only want to have something. And TBH this is some rather basic stuff which you can find answers for by Googling and reading docs. – Sebastian Jan 12 '15 at 16:05

1 Answers1

0

OK, I figured it out. Added this code snippet:

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath:NSIndexPath) -> UITableViewCell {
    //...

    let singleTap = UITapGestureRecognizer(target: self, action: Selector("tapped"))
    singleTap.numberOfTapsRequired = 1
    cell.imageView?.userInteractionEnabled = true
    cell.imageView?.addGestureRecognizer(singleTap)

    //...
}

func tapped() {
        println("tapped!")
}
Daniel
  • 3,758
  • 3
  • 22
  • 43