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

标签 ios swift uitableview uiaccessoryview

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 添加到单元格?

最佳答案

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

请引用:

enter image description here

关于ios - accessoryButtonTappedForRowWithIndexPath 不适用于自定义按钮或标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35867281/

相关文章:

iOS WKWebView 检测何时到达底部

ios - 四舍五入为偶数

swift - AlamofireObjectMapper 无法使用类型为 'responseObject' 的参数列表调用 '((User?, NSError?) -> _)'

swift - 如何创建一个包含多个表格单元格的普通表格,每个表格单元格都链接到自己的推送转场?

ios - 根据 View Controller 设置 UINavigationBar 颜色

ios - NSString 被截断

ios - 使用 timeIntervalSince1970 时 DateFormatter 结果不正确

ios - TableView 单元格不显示更新的数据

iphone - 处理 UITableViewCell 中的按钮

ios - 保持 TableView 之间的数组顺序?