我有UITableCells一个UITable其看起来如下:与卫生组织纽扣电池的索引UITableCell按钮touchUpInside被点击
[myLabel则myButton]
[myLabel则myButton]
[myLabel则myButton]
[myLabel myButton的]
我想我handlerCellButtonClicked也得到的细胞指数的参考。如何在触摸按钮时获得对此索引的引用?
/** called by table to get the cell needed by the index */
-(UITableViewCell*)tableView:(UITableView *) tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
...
//init cell
...
//configure the cells custom button handlers
[cell.myButton addTarget:self action:@selector(handlerCellButtonClicked) forControlEvents:UIControlEventTouchUpInside];
return cell;
}
/** handler when the button in the cell is clicked */
- (void)handlerCellButtonClicked{
NSLog(@"cell myButton clicked");
}
[其中的UIButton在一个UITableView按压检测]的可能重复(http://stackoverflow.com/questions/1802707/detecting-which-uibutton-was-pressed-in-a-uitableview) –