detect a touch down event on UIImageView(s)

后端 未结 4 1383
北恋
北恋 2021-01-06 18:42

I placed 4 UIImageView on UIView and I named them

UIImageView myImg1 = [[UIImageView alloc] init];     
UIImageView myImg2 = [[UIImageView alloc] init];             


        
4条回答
  •  囚心锁ツ
    2021-01-06 19:33

    UITapGestureRecognizer *singleFingerTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];
            singleFingerTap.numberOfTapsRequired = 1;
            [myImg1 addGestureRecognizer:singleFingerTap];
            [myImg2 addGestureRecognizer:singleFingerTap];
            [singleFingerTap release];
    

    And action method

    -(void)handleSingleTap:(UIGestureRecognizer*)sender{
        //your code here
    }
    

提交回复
热议问题