accessoryButtonTappedForRowWithIndexPath not working for custom button or label

836 Views Asked by At
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
      let key =  keyArray[indexPath.section-1]
      let label = UILabel(frame: CGRectMake(0, 0, 26, 28))
      label.center = CGPointMake(26, 28)
      cell.accessoryView = label
}

    override func tableView(tableView: UITableView, accessoryButtonTappedForRowWithIndexPath indexPath: NSIndexPath) {
        print(indexPath)
    }

Why for custom label or custom button not call accessoryButtonTappedForRowWithIndexPath . Or only one way add myButton to cell ?

1

There are 1 best solutions below

2
techloverr On BEST ANSWER

For custom button you can add target for specific event, accessoryButtonTappedForRowWithIndexPath will not work for custom view

Please refer:

enter image description here