为 UITableViewCel l的 accessoryButton 添加事件

来源:互联网 发布:拼拼豆豆软件 编辑:程序博客网 时间:2024/05/07 03:35

如果把 cell 的 accessoryType 设置为 UITableViewCellAccessoryDetailDisclosureButton 

[plain] view plaincopy
  1. cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;  

会有如下所示按钮



但是怎么为 UITableViewCellAccessoryDetailDisclosureButton 定义事件,发现在UITableViewDelegate 可以定义这个按钮的事件 

[plain] view plaincopy
  1. - (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath  
  2. {  
  3.     NSInteger row = indexPath.row;  
  4.     if (row == 0) {  
  5.         NSLog(@"点击了cell右边按钮");  
  6.        //  
  7.     }  
  8. }  
原创粉丝点击