ios - Is it possible to customize swiping gesture recognition that triggers UIScrollView scroll? -
i've created custom subclass uiscrollview
, implemented touchesbegan
, touchesmoved
, touchesended
, touchescancelled
methods.
however i'm not satisfied how things work. particularly, when mentioned methods getting called , when uiscrollview
decide scroll(drag).
uiscrollview
scrolls if difference between first touch point , last touch point little in vertical direction. can swipe horizontally , uiscrollview
going scroll or down depending on small difference.(which fine in normal use cases)
both of these swipes cause uiscrollview
scroll downwards.
however i'm interested possible adjust somehow, behaves this:
basically near horizontal swiping gets picked touchesbegan
, related methods , not initiate scroll. green swiping direction still initiate scrolling...
edit:
i forgot mention, touchesbegan
, relatives called if hold finger short period of time on screen , move around. not classical swiping gesture...
ivan, think trying same effect facebook page is, , drag scrollview , letting scrollview follow finger, if correct, suggest forget touches events, , start uipangesture , best in these cases, inside delegate calls gesture, put following code it:
//the sender view, in case scollview uiscrollview* scr = (uiscrollview*)sender.view; //disable scrolling flag sake of user experience [scr setscrollenabled:false]; //get current translation point of scrollview in respect main view cgpoint translation = [sender translationinview:self.view]; //set view center new translation point float translationpoint = scr.center.x + translation.x; scr.center = cgpointmake(translationpoint,scr.center.y); [sender settranslation:cgpointmake(0, 0) inview:self.view];