ios - UITableView swipe gesture requires near perfect accuracy -
i'm working on custom swipe event uitableview uses custom uitableviewcell subclass. included uigesturerecognizerdelegate
in header, , have in viewdidload:
uiswipegesturerecognizer *swipeleft = [[uiswipegesturerecognizer alloc] initwithtarget:self action:@selector(didswipe:)]; swipeleft.direction = uiswipegesturerecognizerdirectionleft; swipeleft.numberoftouchesrequired = 1; [self.tableview addgesturerecognizer:swipeleft];
my swipeleft method looks so:
-(void)didswipe:(uiswipegesturerecognizer *)recognizer { if (recognizer.state == uigesturerecognizerstateended) { cgpoint swipelocation = [recognizer locationinview:self.tableview]; nsindexpath *swipedindexpath = [self.tableview indexpathforrowatpoint:swipelocation]; nsdictionary *clip = [self.clips objectatindex:swipedindexpath.row]; nslog(@"swiped!"); } }
it's sort of working, swipe has incredibly precise. impossibly precise.
i got working using uipangesturerecognizer instead, unfortunately didn't play nice global side drawer component uses global pan gesture recognizer (ecslidingviewcontroller interested).
is there way around this? appreciated, i've been googling around , browsing hours looking solution.
as pointed out kolin krewinkel on twitter, implementing these 2 delegate methods did trick:
-(bool)gesturerecognizer:(uigesturerecognizer *)gesturerecognizer shouldrecognizesimultaneouslywithgesturerecognizer:(uigesturerecognizer *)othergesturerecognizer { return yes; } - (bool)gesturerecognizershouldbegin:(uigesturerecognizer *)gesturerecognizer { return yes; }
Comments
Post a Comment