美文网首页
添加按钮事件

添加按钮事件

作者: 兰歌er | 来源:发表于2017-11-02 14:24 被阅读5次

添加按钮点击事件:

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

相关文章

网友评论

      本文标题:添加按钮事件

      本文链接:https://www.haomeiwen.com/subject/lsztpxtx.html