美文网首页
点击事件UITapGestureRecognizer传参

点击事件UITapGestureRecognizer传参

作者: 关羽007 | 来源:发表于2019-03-11 15:42 被阅读0次

UIImageView *imageview = [[UIImageView alloc] initWithImage: [UIImage imageNamed:@"tab-me-plese.png"]];

UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(keyboardHide:)];

[imageview setTag:i]; //set tag value

[imageview setUserInteractionEnabled:YES];

[imageview addGestureRecognizer:tap];

- (void)keyboardHide:(UIGestureRecognizer *)sender

{

    NSLog(@"点击了第%ld张图片", sender.view.tag);   

}

相关文章

网友评论

      本文标题:点击事件UITapGestureRecognizer传参

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