我正在尝试在 ios 中进行拖动。如果拖动移动距离很短,我将通过比较 start x,y(来自 touchesBegan)与 touchesEnd 中的 x,y 来将拖动计为单击事件。似乎 touchesEnd 永远不会被调用。我放了一个断点来验证它,断点从未发生过。
code:
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
NSUInteger touchCount = [touches count];
NSUInteger tapCount = [[touches anyObject] tapCount];
[ self UpdateDrag];
}
- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
NSUInteger touchCount = [touches count];
NSUInteger tapCount = [[touches anyObject] tapCount];
}
- (void) touchesEnd:(NSSet *)touches withEvent:(UIEvent *)event {
// this methes never gets called
NSUInteger touchCount = [touches count];
NSUInteger tapCount = [[touches anyObject] tapCount];
if (mDisplay==nil)
{
mDisplay = [[cDisplayYesOrNo_iPhone alloc]
initWithNibName:@"cDisplayYesOrNo_iPhone"
bundle:[NSBundle mainBundle]];
}
[ mDisplay SetUp];
[self presentModalViewController: mDisplay animated:NO];
}