objective c - tap gesture not recognized on uiimageview -
i added 2 uiimageview
s, 1 on subview uiview
(imageview1,imageview2
). in first view top uiimageview
hidden(imageview2
) , in second view bottom imageview
hidden(imageview1
).
allocating tap gesture:
uitapgesturerecognizer *singletap = [[uitapgesturerecognizer alloc] initwithtarget:self action:@selector(onetap:)]; uitapgesturerecognizer *singletap1 = [[uitapgesturerecognizer alloc] initwithtarget:self action:@selector(onetap:)];
set user interaction both uiimageview yes.
[singletap setnumberoftapsrequired:1]; [singletap1 setnumberoftapsrequired:1];
// adding gesture uiimageview
add tap gesture recognizer , selector respectively.
[imageview1 addgesturerecognizer:singletap]; [imageview2 addgesturerecognizer:singletap1];
but taps not recognized.
can 1 tell me mistake is?
try setting setuserinteractionenabled:yes
before adding gesture recognizer.
[imageview1 setuserinteractionenabled:yes] [imageview2 setuserinteractionenabled:yes] [imageview1 addgesturerecognizer:singletap]; [imageview2 addgesturerecognizer:singletap1];
update:
after comment have made suggest bring views top before detecting tap event. because parent imageview above , catches these taps.
[yourparentview bringsubviewtofront:imageview1]; [yourparentview bringsubviewtofront:imageview2];
Comments
Post a Comment