ios - addTarget:action:forControlEvents: ignored when interacting with separate UITapGestureRecognizer -


i'm new ios programming

i have code (abridged) looks following

uiview *somesubview = [[uiview alloc] initwithframe:...]; [self addsubview:somesubview]; [somesubview addtarget:self action:@selector(_handletaponview:) forcontrolevents:uicontroleventtouchupinside];  _tapgesturerecognizer = [[uitapgesturerecognizer alloc] initwithtarget:self action:@selector(_handletap:)]; _tapgesturerecognizer.delegate = self; [self.view addgesturerecognizer:_tapgesturerecognizer]; 

unfortunately gesture recognizer triggers , views addtarget call not. i've tried commenting out gesture recognizer code , works, know not call addtarget on subview.

i solved using gesturerecognizer:shouldreceivetouch: , doing hit test sub view, feel i'm missing fundamental understanding here wouldn't require me adding manual hit test.

its important note don't want code in _handletap in _tapgesturerecognizer execute when have tapped on subview.

any guidance here? thanks!

try using:

_tapgesturerecognizer.cancelstouchesinview = no; 

otherwise gesture recogniser intercept touches , not forward them further (in other words, gesture recogniser gets touch, handles it, , since cancel it, no other object gets touch). not cancelling, touch forwarded other object (recognisers or views) handle it.


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -