【发布时间】:2015-03-11 17:12:44
【问题描述】:
我正在实现一个自定义视图来处理图像的编辑(非常特定的目的),并且一直在处理触摸事件
根据我在覆盖touchesBegan、touchesMoved、touchesEnded 和touchesCancelled 并实现它们之后的逻辑,因此如果触摸击中目标(视图的一部分),我正在处理事件和 _not_ 调用 [super touchesXXX] 事件不应传递给其父级 UIResponders
但是,我的观点是UIPageViewController,并且触摸事件运行良好,但由于某种原因,UIPageViewController 也始终接收事件并通过滑动手势接管,这使我无法执行需要的操作touchesMoved,因为每次触摸水平移动时UIPageViewController 都会将其识别为滑动
所以基本上我的代码如下:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
if([self withinBounds:touches]) {
//do own stuff
} else {
[super touchesBegan:touches withEvent:event];
}
}
我已经完成了调试打印,一切正常,直到我进行水平移动,它从不调用 super 的 touchesBegan 或 touchesMoved 或任何东西,但手势被激活
我还尝试通过设置自定义 UIGestureRecognizer 委托来覆盖手势,该委托在 shouldReceiveTouch 方法上始终返回 NO,但滑动手势仍在继续
如果重要的话,我的目标平台是 iOS 8.1,我正在模拟器上运行应用程序
【问题讨论】:
-
resignFirstResponder或类似的东西怎么样? iOS 应用程序分别积极使用责任链模式来处理事件和触摸事件。
标签: objective-c iphone uiview uigesturerecognizer uipageviewcontroller