iOS swipe gesture Uipangesturerecognizer considerations

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.