简体   繁体   English

accessoryButtonTappedForRowWithIndexPath不适用于自定义按钮或标签

[英]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 . 为什么自定义标签或自定义按钮不能调用accessoryButtonTappedForRowWithIndexPath Or only one way add myButton to cell ? 或者只有一种方法将myButton添加到单元格?

For custom button you can add target for specific event, accessoryButtonTappedForRowWithIndexPath will not work for custom view 对于自定义按钮,您可以为特定事件添加目标, accessoryButtonTappedForRowWithIndexPath将不适用于自定义视图

Please refer: 请参考:

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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