添加按钮事件

2017-11-02  本文已影响5人  兰歌er

添加按钮点击事件:

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

上一篇 下一篇

猜你喜欢

热点阅读