我有一个UILongGestureRecognizer UIView,我在视图中添加了UIPanGestureRecognizer和。当我点击并握住它几秒钟时,就会得到LongPress识别的回调。
代码如下所示
- (void)addPanGsetureForView:(UIView *)object
{
UIPanGestureRecognizer * panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGestureRecognised:)];
[object addGestureRecognizer:panGesture];
[panGesture release];
}
- (void)addLongPressGsetureForView:(UIView *)object
{
UILongPressGestureRecognizer * longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(imageLongPressed:)];
[longPress setMinimumPressDuration:1.0];
[object addGestureRecognizer:longPress];
[longPress release];
}所以我想用潘手势移动视图。因此,当长按压被识别而不移除我在视图上的手指时,我想让pan手势被识别。如果我移开我的手指,再点击和平底,它就会被识别出来。
所以请帮助我这个问题。
提前感谢
发布于 2012-08-20 07:42:05
摘自苹果关于手势识别器的文档
允许同时进行手势识别
默认情况下,没有任何两个手势识别器可以尝试同时识别它们的手势。但是您可以通过实现gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer: ( UIGestureRecognizerDelegate协议的一种可选方法)来改变这种行为。当接收手势识别器的识别将阻止指定手势识别器的操作时,则调用此方法,反之亦然。返回“是”以允许两个手势识别器同时识别它们的手势。
刚刚测试了这个,我想它会解决你的问题!
https://stackoverflow.com/questions/12033631
复制相似问题