ios - 苹果手机SDK : how to distinguish between touch and drag

标签 ios iphone objective-c drag popover

我正在使用 2 个 pod。

MMDrawerController 0.5.1& WYPopoverController 0.1.7

现在我想在我的 MMView 上制作一个 WYPopover

一些图片:

这就是 MMController 的样子(Playground)

some playground

现在我想在任何地方触摸它,让它看起来像:

normal when touched

错误:如果我想从“MMController”打开左 View ,有时我会得到这个:

the error

但它应该看起来像(左 MMControllerView)

enter image description here

我正在使用两种方法:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
// show the popoverController
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    [popController dismissPopoverAnimated:NO];
}

我的问题:为什么 touchesMoved 不称为连续的,是否有更好的方法?

最佳答案

我对你提到的“ pod ”一无所知(CocoaPods?)但是,区分点击和拖动的最直接方法是使用一对手势识别器,一个点击手势识别器和一个平移手势识别器,并设置点击手势识别器,以便在触发点击之前平移手势必须失败(手势识别器中内置了“等待另一个手势识别器失败”机制。)

我建议阅读 UIGestureRecognizer,以及特定类 UITapGestureRecognizer 和 UIPanGestureRecognizer

关于ios - 苹果手机SDK : how to distinguish between touch and drag,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20892433/

相关文章:

iphone - 为什么我在 iOS 上使用 tan() 函数会遇到这个问题?

ios - dispatch_after block 未运行

iphone - 使用 Core Motion 和 CATransform3D 旋转图像

ios - 录制时向我的视频添加音频 - Swift 4

ios - 在 iOS 中点击标签后是否可以更改场景?

ios - 无法使用类型为 'init' 的参数调用 'NSNumber' (Swift)

iphone - 如何修改 FlowCover 示例应用程序以水平工作?

ios - 从对象到 json 文本 ios 的转换

iphone - Objective C 贝塞尔曲线 reshape

ios - CloudKit,无法修改某些记录 - 未找到区域