伙计们,
我添加了两个UILongPressGestureRecognizer.我想要的是当按下两个按钮0.3秒时,启动"shortPressHandler".如果用户再按下这两个按钮1.2秒,则启动"longPressHandler".现在我只得到shortPressHandler启动并且longPressHandler从未被解雇.我认为这可能是因为shortPressGesture首先被识别而longPressGesture永远不会有机会.任何人都可以告诉我如何实现我想要的东西吗?提前致谢.
UILongPressGestureRecognizer *longPressGesture =[[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressHandler:)] autorelease];
longPressGesture.numberOfTouchesRequired = 2;
longPressGesture.minimumPressDuration = 1.5;
longPressGesture.allowableMovement = 10;
longPressGesture.cancelsTouchesInView = NO;
longPressGesture.enabled = true;
[self.view addGestureRecognizer:longPressGesture];
UILongPressGestureRecognizer *shortPressGesture =[[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(shortPressHandler:)] autorelease];
shortPressGesture.numberOfTouchesRequired = 2;
shortPressGesture.minimumPressDuration = 0.3;
shortPressGesture.allowableMovement = 10;
shortPressGesture.cancelsTouchesInView = NO;
shortPressGesture.enabled = true;
[self.view addGestureRecognizer:shortPressGesture];
Run Code Online (Sandbox Code Playgroud) 我在这里有一个问题。我心里似乎有些复杂。希望我能把自己说清楚。:)
是否可以?