ios - UISwipeGestureRecognizer blocked by UITapGestureRecognizer -


i have view needs handle pan, tap, , swipe gestures. have pan , tap working, when add swipe, doesn't work. curiously, seems tap somehow blocks swipes because if remove tap, swipe works fine. here's how create gesture recognizers.

- (void) initgesturehandlers {     uiswipegesturerecognizer *swipeleftgesture = [[uiswipegesturerecognizer alloc] initwithtarget:self action:@selector(handleswipeleftgesture:)];     swipeleftgesture.numberoftouchesrequired = 1;     swipeleftgesture.direction = uiswipegesturerecognizerdirectionleft;     [self addgesturerecognizer:swipeleftgesture];      uiswipegesturerecognizer *swiperightgesture = [[uiswipegesturerecognizer alloc] initwithtarget:self action:@selector(handleswiperightgesture:)];     swiperightgesture.numberoftouchesrequired = 1;     swiperightgesture.direction = uiswipegesturerecognizerdirectionright;     [self addgesturerecognizer:swiperightgesture];      uitapgesturerecognizer *tapgesture = [[uitapgesturerecognizer alloc] initwithtarget:self action:@selector(handletapgesture:)];     [tapgesture setnumberoftapsrequired:1];     [self addgesturerecognizer:tapgesture];      uipangesturerecognizer *pangesture = [[uipangesturerecognizer alloc] initwithtarget:self action:@selector(handlepangesture:)];     [self addgesturerecognizer:pangesture]; } 

a lot of blog suggest using requiregesturerecognizertofail handle case tap fires before double tap fires, tried that, didn't work.

    [tapgesture requiregesturerecognizertofail:swipeleftgesture];     [tapgesture requiregesturerecognizertofail:swiperightgesture]; 

how can tap , swipe in same view?

comment or remove lines

 //[tapgesture requiregesturerecognizertofail:swipeleftgesture];  //[tapgesture requiregesturerecognizertofail:swiperightgesture]; 

also set guesture objects delegate self. this

- (void) initgesturehandlers {     uiswipegesturerecognizer *swipeleftgesture = [[uiswipegesturerecognizer alloc] initwithtarget:self action:@selector(handleswipeleftgesture:)];     swipeleftgesture.numberoftouchesrequired = 1;     swipeleftgesture.direction = uiswipegesturerecognizerdirectionleft;     swipeleftgesture.delegate = self;     [self addgesturerecognizer:swipeleftgesture];      uiswipegesturerecognizer *swiperightgesture = [[uiswipegesturerecognizer alloc] initwithtarget:self action:@selector(handleswiperightgesture:)];     swiperightgesture.numberoftouchesrequired = 1; swiperightgesture = self;     swiperightgesture.direction = uiswipegesturerecognizerdirectionright;     [self addgesturerecognizer:swiperightgesture];      uitapgesturerecognizer *tapgesture = [[uitapgesturerecognizer alloc] initwithtarget:self action:@selector(handletapgesture:)];     [tapgesture setnumberoftapsrequired:1];     [self addgesturerecognizer:tapgesture]; tapgesture.delegate = self;      uipangesturerecognizer *pangesture = [[uipangesturerecognizer alloc] initwithtarget:self action:@selector(handlepangesture:)];     [self addgesturerecognizer:pangesture]; pangesture.delegate = self; } 

implement delegate method this

- (bool)gesturerecognizer:(uigesturerecognizer *)gesturerecognizer shouldrecognizesimultaneouslywithgesturerecognizer:(uigesturerecognizer *)othergesturerecognizer {     return yes; } 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -