Is it possible to use gesture recognizers with layers? Let's say I want to add several sublayers to my view and implement drag&drop as well as tapping on single element. Is it possible at all ? What is the best pattern?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You could try adding gesturerecognizers to your UIView
and then call
- (CALayer *)hitTest:(CGPoint)thePoint
on your view's layer to find which layer you hit, eg;
CALayer* layerThatWasTapped = [gestureView.layer hitTest:[gestureRecognizer locationInView:gestureView]];