将手势传递到视图在z轴上的排列

这是我的代码….

UIView *View1 = [[UIView alloc] initWithFrame:CGRectMake(0, 300, 1000, 150)]; UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(callTap)]; [View1 addGestureRecognizer:tap]; view1.userInteractionEnabled = true; view1.layer.zPosition=1; [self.view addSubview:view1]; UIView *View2 = [[UIView alloc] initWithFrame:CGRectMake(0, 300, 1000, 150)]; UIPinchGestureRecognizer *pinch = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(callPinch)]; [View2 addGestureRecognizer:pinch]; View2.userInteractionEnabled= true; View2.layer.zPosition=2; [self.view addSubview:View2]; UIView *View3 = [[UIView alloc] initWithFrame:CGRectMake(0, 300, 1000, 150)]; UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(callPan)]; [View3 addGestureRecognizer:pan]; View3.userInteractionEnabled=true; View3.layer.zPosition=3; [self.view addSubview:View3]; 

我想让视图只识别代码中添加的单个手势,并将其他手势传递给下面的视图….
如何实现这一function?

这个问题很容易回答…..
当在ios中识别Gesture时,最顶层的视图总是接收用户的触摸,因此手势识别取决于您的子视图如何堆叠意味着它如何在SuperView的属性命名为子视图中排列….如果多个子视图保持相同的接触点屏幕然后在子视图中具有更高索引值的视图将获得触摸…通常具有更高索引值的视图也将在其他人之上可见….

当涉及到ZPosition时,它会使一些有趣的事情。将ZPosition更改为更高的值使得视图可见而不会对索引位置进行任何更改。因此,在这种情况下,索引零上的子视图也可能完全可见,但它不会t意味着它将接收所有的触摸,因为它仍然在零索引…..如果你想让零索引子视图接收所有的触摸,那么使用UIView类的方法将它置于其他人之上。 …
不要同时使用Gesture和ZPosition,它可能会在与您的应用交互时混淆用户。