点击事件UITapGestureRecognizer传参

2019-03-11  本文已影响0人  关羽007

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);   

}

上一篇下一篇

猜你喜欢

热点阅读