我正在尝试在 ios 中进行拖动。如果拖动移动的距离很短,我将通过比较起始 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];
}
最佳答案
是 - (void)touchesEnded:
不是 - (void)touchesEnd:
关于ios - touchesEnd 未被调用位 touchesBegin 和 touchesMoved 确实被调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18857736/