2016-03-08 47 views
4
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不适用于自定义按钮或标签

回答

6

对于自定义按钮,你可以为特定的事件添加目标,accessoryButtonTappedForRowWithIndexPath不会为自定义视图工作

请参考:

enter image description here

+0

可以请你分享提及不与自定义按钮的工作一份文件。因为这里说http://stackoverflow.com/questions/12296904/accessorybuttontappedforrowwithindexpath-not-getting-called –

+0

检查更新的答案 – techloverr

+0

感谢您的信息。 :) –