ios - is it possible to add a GestureRecognizer to a label in a custom UIView subview -


i refactoring viewcontroller have adopted , creating uiviews in controller code. i'd move custom uiview handle gesture recognizer in controller.

i have itemviewcontroller has custom uiview. within itemcontroller, i'd like:

itemview *itemview = [[itemview alloc] initwithframe:cgrectmake(30.0f,_runningyposition,100.0f, 50.0f)]; uitapgesturerecognizer *taprecognizer2 = [[uitapgesturerecognizer alloc] initwithtarget:self action:@selector(taprecognized:)]; itemview.miheaderlabel.tag = [item itemid]; [itemview.miheaderlabel addgesturerecognizer: taprecognizer2]; 

that references

- (void)taprecognized:(id)sender {     ... } 

in itemviewcontroller (not in custom view).

but doesn't seem work. possible add gesturerecognizer label property of subview in viewcontroller? obvious i'm doing wrong?

you need set userinteractionenabled yes on label accept touches (and therefore gesture receive touches).


Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -