新增按鈕事件

weixin_34321977發表於2017-11-02

新增按鈕點選事件:

[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是任意型別。

相關文章