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);
}
网友评论