简体   繁体   中英

accessoryButtonTappedForRowWithIndexPath not working for custom button or label

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 ?

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

Please refer:

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM