Objective c 目标C-触摸检测
我正在为一个应用程序制作一个图像库部分。Objective c 目标C-触摸检测,objective-c,Objective C,我正在为一个应用程序制作一个图像库部分。 我怎样才能在稍有延迟的情况下检测到抽头?就像照片应用程序如何在隐藏导航和显示导航之间切换一样 这就是我现在使用的方法 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { } 它工作得很好,但是,轻触和滑动图像让应用看起来很混乱。比如,我打算刷卡,但水龙头也会打开 谢谢你, Tee您需要实现这三种方法,如下所示: - (void)touchesBegan:(NSSet *)
我怎样才能在稍有延迟的情况下检测到抽头?就像照片应用程序如何在隐藏导航和显示导航之间切换一样 这就是我现在使用的方法
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
}
它工作得很好,但是,轻触和滑动图像让应用看起来很混乱。比如,我打算刷卡,但水龙头也会打开
谢谢你,Tee您需要实现这三种方法,如下所示:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
_touchMoved = NO;
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
_touchMoved = YES;
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
if ( !_touchMoved ) {
// good we just tapped!
// here you can also check for time difference between when touches began and ended
}
}
然而,如果“长按”是你正在寻找的,那么考虑使用手势识别器,特别是“代码> UILUnPress SurviurReCnngisher 。您可以创建
UILongPressGestureRecognizer
的实例,并使用在任何UIView
上定义的-(void)addGestureRecognizer:(UIGestureRecognizer*)gestureRecognizer
将其附加到视图中