get index or tag value from imageview tap gesture

后端 未结 6 548
情深已故
情深已故 2020-12-09 11:04

\"enter

This is the image from app store whenever we search for any app. I also want t

6条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-09 11:53

    Add gesture recognizer to the necessary image view:

    UITapGestureRecognizer *frameTapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(frameTapGesture:)];
    [_imgView addGestureRecognizer:frameTapGesture];
    

    Then in the gesture handler get access to the view gesture recognizer attached to:

    - (void)frameTapGesture:(UITapGestureRecognizer*)sender
    {
        UIView *view = sender.view; //cast pointer to the derived class if needed
        NSLog(@"%d", view.tag);
    }
    

提交回复
热议问题