objective c - ios make navigation bar clickable -


just trying make navigationbar of navigationcontroller clickable. works

uitapgesturerecognizer* taprecon = [[uitapgesturerecognizer alloc]                                     initwithtarget:self action:@selector(togglemenu)]; taprecon.delegate = self; taprecon.numberoftapsrequired = 1; [self.navigationbar addgesturerecognizer:taprecon]; 

but when have button, impossible click on (the gesture might take on button).

so, tried found here :

- (bool)gesturerecognizer:(uigesturerecognizer *)gesturerecognizer shouldreceivetouch:(uitouch *)touch {     return (![[[touch view] class] issubclassofclass:[uibutton class]]); } 

and nothing, because [touch view] alway uinavigationbar...

last thing tried setting cancelstouchesinview no. it's ok, can click on button, togglemenu action of uitapgesturerecognizer still called.

do have idea make button works again, not calling togglemenu @ same time ?

thanks !

edit :

juste found how :

- (bool)gesturerecognizer:(uigesturerecognizer *)gesturerecognizer shouldreceivetouch:(uitouch *)touch {     (uiview* sub in self.navigationbar.subviews) {         nsstring *cl = nsstringfromclass([sub class]);         if ([cl isequaltostring:@"uinavigationitembuttonview"]) {             cgrect bback = sub.frame;             cgpoint pointinview = [touch locationinview:gesturerecognizer.view];             return !cgrectcontainspoint(bback, pointinview);         }     }     return yes; } 

well can make button surrounds nav bar, , make button pressing back. sure arrange on top of nav bar button in ib


Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -