【问题标题】:accessoryButtonTappedForRowWithIndexPath not working for custom button or label附件ButtonTappedForRowWithIndexPath 不适用于自定义按钮或标签
【发布时间】:2016-03-08 12:21:40
【问题描述】:
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)
    }

为什么自定义标签或自定义按钮不调用 accessoryButtonTappedForRowWithIndexPath 。还是只有一种方式将 myButton 添加到单元格?

【问题讨论】:

    标签: ios swift uitableview uiaccessoryview


    【解决方案1】:

    对于自定义按钮,您可以为特定事件添加目标,accessoryButtonTappedForRowWithIndexPath 不适用于自定义视图

    请参考:

    【讨论】:

    猜你喜欢
    • 2018-07-30
    • 2015-05-09
    • 2016-05-14
    • 2013-05-24
    • 2013-04-15
    • 2012-06-03
    • 2021-03-27
    • 1970-01-01
    • 2013-01-30
    相关资源
    最近更新 更多