Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

daproject85

macrumors member
Original poster
Apr 13, 2011
37
0
Hi Forum,

i want to see if anyone can please explain the difference between these two methods for me. I have read the apple docs over and over again but i do not understand the difference. So here is my code... in my view controller i have

Code:
 UITapGestureRecognizer *tripleTapToAdjustOrigin = [[UITapGestureRecognizer alloc]
                                                        initWithTarget:self.graphview 
                                                        action:@selector(tripleTapToAdjustOrigin:)];
    tripleTapToAdjustOrigin.numberOfTapsRequired = 3;
    [self.graphview addGestureRecognizer:tripleTapToAdjustOrigin];

and in my view class i have the method "tripleTapToAdjustOrigin" and in it i have

Code:
- (void)tripleTapToAdjustOrigin:(UITapGestureRecognizer *)gesture
{
    if((gesture.state == UIGestureRecognizerStateEnded))
       {
           self.axisOrigin = [gesture locationInView:self];
       }
}

when i use locationInView it works perfectly, if i use locationOfTouch:0 inView:self also works, but picking any number other than 0 , like 1 or 2 crashes my program. My (incomplete) understanding is that the index determines which touch we are interested it....so how does it really work? i will really appreciate the help.
 
Since you're detecting a triple-tap, all touches will have occurred at the same location (basically). Therefore, there will only be one touchIndex (at index 0) for you to query. If you had been trying to detect multi-touches (i.e. more than one touch in multiple locations), then you would be able to access touches beyond the 0 index.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.