添加按鈕點擊事件:
[cell.buttonLeft ? addTarget:selfaction:@selector(onClickLeft:)
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? forControlEvents:UIControlEventTouchUpInside];
//獲取所在cell
cell.buttonLeft.tag = indexPath.row;
-(void)onClickLeft:(UIButton *)sender{
//輸出所在cell行數
[sender tag];
NSLog(@"我是第%li行左邊按鈕",(long)sender.tag);
}
由于知道是UIButton類型。換成id是任意類型。