Today, when doing a slide-off page, it is found that the page slides with the swipe gesture, to the critical point, if the slide will appear jitter phenomenon. Finding a solution is to judge once before entering the method, and then deciding to slide the page within the sliding range. The slide gesture (Uipangesturerecognizer Note summarizes the following:
Code:
-(void) Panaction: (uipangesturerecognizer *) pan{
_canleft = YES;
_canright = YES;
position of//point relative to the previous point
cgpoint moviepoint = [pan translationinview:p an. View];
// point speed ( positive or negative to determine the sliding trend )
cgpoint velocity = [pan velocityinview:p an. View];
//Side -slip range
cgfloat instance = kscreenwidth - N;
// Prohibit left stroke ( at the far left )
if (pan. View. Left <= 0 && moviepoint. X <= 0) {
_canleft = NO;
}
// Prohibit right stroke ( at the far right )
if (pan. View. Left >= instance && moviepoint. X >= 0) {
_canright = NO;
}
// page can slide the condition
if (_canright && _canleft && pan. View. Left >= 0 && pan. View. Left <= instance) {
// mobile
Pan. View. Center =
cgpointmake(pan. View. Center. X + moviepoint. x, pan. View. Center. Y);
}
// reset required every time
[Pan settranslation:cgpointzero inview:p an. View];
// when releasing the finger, judge the sliding trend to return the position .
if (pan. state = = uigesturerecognizerstateended) {
if (pan. View. Left < ) {
Pan. View. Left = 0;
}Else if(pan. View. Left > Instance ) {
Pan. View. Left = instance;
}
}
}
iOS swipe gesture Uipangesturerecognizer considerations