
Untitled
By: a guest on
Jul 1st, 2012 | syntax:
None | size: 0.67 KB | hits: 12 | expires: Never
Recognize that in which direction a control dragged
@interface YourImageView : UIImageView
{
CGPoint previousPt;
//Other iVars.
}
@end
@implementation YourImageView
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
previousPt = [[touches anyObject] locationInView:self.view];
}
- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
const CGPoint p = [[touches anyObject] locationInView:self.view];
if (previousPt.x > p.x)
{
//Dragged right to left
}
else if (previousPt.x < p.x)
{
//Dragged left to right
}
else
{
//no move
}
//Do the same thing for y-direction
}