ios - Restrict angle of swipe to scroll UIScrollView -
i have vertical scroll view needs scrollable want use left , right swipe gestures else. have behavior each swipe direction working, want restrict angle of swipe scrolls uiscrollview, has really, vertical, , left or right leaning swipes activate other behavior , not change scroll position.
i know can swipe angle overriding scrollviewdidscroll , comparing previous , current contentoffset, cannot stop scrollview scrolling there.
how can limit angle of swipe scrolls uiscrollview ?
i think scrollviewdidscroll late want achieve.
maybe try setting directionallockenabled property of uiscrollview yes.(not sure if helps... play it)
and/or implement uiscrollviewdelegate method - (void)scrollviewwillbegindragging:(uiscrollview *)scrollview , within methods implementation grab pointer pangesturerecognizer (readonly) property of uiscrollview passed in.
from there call translationinview: on uipangesturerecognizer, passing in view in coordinate system translation of pan gesture should computed, , cgpoint returned use trigonometry calculate angle , if it's not within predetermined limits call settranslationinview: on uipangesturerecognizer restore.
Comments
Post a Comment