tap gesture not recognized on uiimageview

前端 未结 2 897
星月不相逢
星月不相逢 2020-12-08 19:47

I added two uiimageviews, one on another subview uiview (imageview1,imageview2). In the first view the top uiimageview is

2条回答
  •  孤街浪徒
    2020-12-08 20:02

    Try setting setUserInteractionEnabled:YES before adding gesture recognizer.

    [imageview1 setUserInteractionEnabled:YES]
    [imageview2 setUserInteractionEnabled:YES]
    
    [imageview1 addGestureRecognizer:singleTap];
    [imageview2 addGestureRecognizer:singleTap1];   
    

    Update:

    After the comment you have made I suggest you bring your views to the top before detecting the tap event. Because parent imageView is above and catches these taps.

    [yourparentview bringSubviewToFront:imageview1];
    [yourparentview bringSubviewToFront:imageview2];
    

提交回复
热议问题