我正试图在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];
}
答案 0 :(得分:6)
- (void)touchesEnded:
不是- (void)touchesEnd:
答案 1 :(得分:4)
您需要将touchesEnd
修改为touchesEnded
。
另外,为了完整起见,您需要考虑在某些情况下是否还需要回复touchesCancelled
而不是touchesEnded
。