UITapGestureRecognizer selector, sender is the gesture, not the ui object

后端 未结 4 653
难免孤独
难免孤独 2021-01-31 07:47

I have a series of imageviews that I identify using their tag. I have added a single tap gesture to the images.

UITapGestureRecognizer *singleTap = [[UITapGest         


        
4条回答
  •  独厮守ぢ
    2021-01-31 08:24

    If you need distinct functionality for the handler you might check out the BlocksKit project and this file in particular. The project is a CocoaPods project so you can install it easily into your toolchain.

    An example from the first referenced code file:

    UITapGestureRecognizer *singleTap = [UITapGestureRecognizer recognizerWithHandler:^(id sender) {
         NSLog(@"Single tap.");
     } delay:0.18];
     [self addGestureRecognizer:singleTap];
    

    This could effectively allow you to setup a gesture recognizer easily for each image.

提交回复
热议问题