iphone - Problem capturing single/double taps inside a ScrollView -


i'm posting message because i've been reading forum , haven't been able find similar problem. need able discriminate taps , double taps (this standard thing) problem whatever reasons have scroll view inside scrollview. so, had sub-class scrollview in order touchedbegin method called.

i have class called photoviewcontroller (a sub-class of baseviewcontroller) class contains class called customscrollview (a subclass of scrollview). needed sub-class customscrollview scrollview in order override touchesbegin method, , able capture touches made user.

i tried calling touchesbegin method customscrollview using return [super touchesbegan:touches withevent:event] inside touchesbegin method, when touchesbegin method inside photoviewcontroller gets called it's parameters empty (and can't discriminate if user made single or double tap, need)

i have class, called photoviewcontroller:

@class photoviewcontroller @interface photoviewcontroller : baseviewcontroller  <uiscrollviewdelegate> {      customscrollview*           myscrollview;  }  @implementation photoviewcontroller  ...  - (void)touchesbegan:(nsset *)touches withevent:(uievent *)event {     uitouch *touch = [touches anyobject];      nsuinteger tapcount = [touch tapcount];      switch (tapcount) {         case 1:              [self performselector:@selector(singletapmethod) withobject:nil afterdelay:.4];             break;         case 2:              [nsobject cancelpreviousperformrequestswithtarget:self selector:@selector(singletapmethod) object:nil];             [self performselector:@selector(doubletapmethod) withobject:nil afterdelay:.4];             break;         default:             break;     }  } 

the class customscrollview (customscrollview.h):

@interface customscrollviewphoto : uiscrollview { }  - (void)touchesbegan:(nsset *)touches withevent:(uievent *)event;  @end 

and it's implementation this(customscrollview.m):

@implementation customscrollviewphoto  - (void)touchesbegan:(nsset *)touches withevent:(uievent *)event {         [self.superview touchesbegan:[nsset set] withevent:event];     return [super touchesbegan:touches  withevent:event]; } 

am going in wrong direction want do? maybe, should capture taps/double taps inside customscrollview class(this works fine!), , there using @selector or call appropiate methods in photoviewcontroller?

thanks reading!

i think you're going wrong route (only slightly!). similar thing in photo viewer , capture touches in customscrollview. shouldn't need in photoviewcontroller.

- (void)touchesended:(nsset *)touches withevent:(uievent *)event {     [super touchesended:touches withevent:event];      uitouch *touch = [touches anyobject];      if(touch.tapcount == 2)     {         if (self.zoomscale == self.minimumzoomscale)         {             //zoom user has clicked             cgpoint pos = [touch locationinview:self];             [self zoomtorect:cgrectmake((pos.x - 5.0)/self.zoomscale, (pos.y-5.0)/self.zoomscale, 10.0, 10.0) animated:yes];         }         else         {             //zoom out full size             [self setzoomscale:self.minimumzoomscale animated:yes];         }     } } 

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 -