ios---多张图片加手势,如何判断图片的tag

    self.ImgView1.tag = 0;

    self.ImgView2.tag = 1;



UITapGestureRecognizer *tapGesture= [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(ClickPicture:)];

    [self.ImgView1 addGestureRecognizer:tapGesture];

    self.ImgView1.userInteractionEnabled = YES;

    

    UITapGestureRecognizer *tapGesture2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(ClickPicture:)];

    [self.ImgView2 addGestureRecognizer:tapGesture2];

    self.ImgView2.userInteractionEnabled = YES;




-(void) ClickPicture:(UITapGestureRecognizer *)sender{

    

    UITapGestureRecognizer *tap = (UITapGestureRecognizer*)sender;

    UIView *views = (UIView*) tap.view;

    NSLog(@" tag %ld ",(long)views.tag);

}

猜你喜欢

转载自blog.csdn.net/iotjin/article/details/80307644