objective c - Recognition of swipe with two touches in UIScrollView -


i have uiscrollview full screen size (ipad, 1024x768, landscape mode). need recognize swipe 2 finger in direction on it. that's have (mainscroll property of class):

//myviewcontroller.h - (void)loadview {      mainscroll = [[uiscrollview alloc] initwithframe:cgrectmake(0, 0, 1024, 768)];      mainscroll.contentsize = cgsizemake(1024*pagenumber, 768);      mainscroll.pagingenabled = yes;      mainscroll.delegate = self;      [self.view addsubview:mainscroll];       gesturerecognizer *tapinterceptor = [[gesturerecognizer alloc] init];      tapinterceptor.numberoftouchesrequired = 2;      tapinterceptor.direction = uiswipegesturerecognizerdirectionup | uiswipegesturerecognizerdirectiondown | uiswipegesturerecognizerdirectionleft | uiswipegesturerecognizerdirectionright;      [mainscroll addgesturerecognizer:tapinterceptor];      mainscroll.userinteractionenabled = yes; } 

and

//gesturerecognizer.h - (void)touchesbegan:(nsset *)touches withevent:(uievent *)event {      if ([touches count] > 1)          nslog(@"started"); }  - (void)touchesmoved:(nsset *)touches withevent:(uievent *)event {      if ([touches count] > 1)          nslog(@"moved"); }  - (void)touchesended:(nsset *)touches withevent:(uievent *)event {      if ([touches count] > 1)          nslog(@"ended"); } 

i had add condition

if ([touches count] > 1) 

because works not 2 (ore more) touches, one.

but swipe (with 2 touches) still scrolls uiscrollview. how can prevent it? how can recognize swipe without effect on scrollview?

the documentation of uigesturerecognizer gives explanation of each of 3 following properties:

cancelstouchesinview — if gesture recognizer recognizes gesture, unbinds remaining touches of gesture view (so window won’t deliver them). window cancels delivered touches (touchescancelled:withevent:) message. if gesture recognizer doesn’t recognize gesture, view receives touches in multi-touch sequence.

delaystouchesbegan — long gesture recognizer, when analyzing touch events, has not failed recognition of gesture, window withholds delivery of touch objects in uitouchphasebegan phase attached view. if gesture recognizer subsequently recognizes gesture, view not receive these touch objects. if gesture recognizer not recognize gesture, window delivers these objects in invocation of view’s touchesbegan:withevent: method (and possibly follow-up touchesmoved:withevent: invocation inform of touches current location).

delaystouchesended — long gesture recognizer, when analyzing touch events, has not failed recognition of gesture, window withholds delivery of touch objects in uitouchphaseended phase attached view. if gesture recognizer subsequently recognizes gesture, touches cancelled (in touchescancelled:withevent: message). if gesture recognizer not recognize gesture, window delivers these objects in invocation of view’s touchesended:withevent: method.

there more here: uigesturerecognizer.

i'm thinking want either "delaystouchesbegan" or "delaystouchesended" scroll view won't receive of touches (ie scrolling view) until gesture fails it's requirements.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -