Can drag gesture can obtain the time when a drag gesture between two adjacent distance it is not possible to set an intermediate variable to be calculated.
Reply:
If you use other methods to achieve using touchesBegain drag, you can be implemented as follows:
- (Void) touchesBegan: (NSSet *) touches withEvent: (UIEvent *) event
{
/ / Record the starting position, _ptMarked needs to be defined as a member variable
_ptMarked = [[touches anyObject] locationInView: self];
}
- (Void) touchesMoved: (NSSet *) touches withEvent: (UIEvent *) event
{
CGPoint ptCurrent = [touches anyObject] locationInView: self];
/ / Calculate the current contact and the distance between the initial contact
CGFloat distance = sqrt (pow ((ptCurrent.x-_ptMarked.x), 2.0) + pow ((ptCurrent.y-_ptMarked.y), 2.0));
}
No comments:
Post a Comment