简体   繁体   English

在使用手势识别器呈现视图时如何检测触摸?

[英]How to detect touch while presenting views with gesture recognizers?

I have been developing collage like application. 我一直在开发类似应用程序的拼贴。 In which user can add images, they can scale, move and rotate them. 用户可以在其中添加图像,它们可以缩放,移动和旋转图像。 Whenever, I am trying to drag an image which is on top but added earlier than the one behind it, it is not receiving the gesture, rather than the one behind it which is added later gets detected and brought into front. 每当我尝试拖动位于顶部但要比其后面的图像早添加的图像时,它都不会收到手势,而是要检测到其后添加的图像,并将其置于前面。 How to resolve this issue? 如何解决这个问题?

我正在使用它在第二个视图中删除手势...

 [imageView1 removeGestureRecognizer:GestureInView2];

This are the delegate method of UIGestureRecognizer you can use for your different requirement. 这是UIGestureRecognizer的委托方法,可用于您的不同需求。

touchesBegan:withEvent:
touchesMoved:withEvent:
touchesEnded:withEvent:

I didn't understand your issue perfectly, But. 我不太了解您的问题,但是。 I think you have to refer for more detail according to your requirement - https://developer.apple.com/library/ios/documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/GestureRecognizer_basics/GestureRecognizer_basics.html . 我认为您必须根据您的要求参考更多详细信息-https: //developer.apple.com/library/ios/documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/GestureRecognizer_basics/GestureRecognizer_basics.html

I have done it. 我已经做了。 We need to change the index of subviews if you want to make them receive touches. 如果要使子视图接收触摸,我们需要更改子视图的索引。 Changing zposition alone will not help to make the view to receive touches. 仅更改zposition并不能使视图接收到触摸。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM