I'm trying to realize an app that requires to move an UIImageView, that is put behind a transparent grid. How can I make it? This is the code:

[[self view] addSubview:myimage];
myimage.userInteractionEnabled = YES;
UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)];
[panGesture setDelegate:self];
[myimage addGestureRecognizer:panGesture];
[self.view addSubview:over];

The transparent layer is "over". If it is not added to the view, my pan method works. When I add it, nothing works. So, how can I move my image behind the transparent grid? Thank you everybody.

有帮助吗?

解决方案

make over not clickable by setting userInteraction to no


if that doesn't work for some reason, use a custom class for over and override pointInside to always return NO :D

其他提示

You can add aUIImageView as transparent layer over your image, and as UIImageView have by default userInteractionDisabled don't change that.

It's because if overlay image have user interaction then that would not let that pass to background view but 'll consume touches. Hence to enable panning on back ground view you need to pass touches on that view. By some approach. One of those is what I told you.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top