如何在多个UIImageView上使用平移手势

时间:2011-09-05 14:44:23

标签: uiview uiimageview gesture multiview

我开发了具有许多视图的应用程序,但是当我想使用平移手势移动某个视图(backgndView)时,另一个视图被移动了。看起来我想要的视图不活跃。这是代码。

//---pan gesture---
UIPanGestureRecognizer *panGesture =
[[UIPanGestureRecognizer alloc]
 initWithTarget:self
 action:@selector(handlePanGesture:)];

[backgndView addGestureRecognizer:panGesture];
[frameView addGestureRecognizer:panGesture];
[effectView addGestureRecognizer:panGesture];
[itemView addGestureRecognizer:panGesture];
[extraView addGestureRecognizer:panGesture];
[panGesture release]; 

我认为extraView对于手势而不是其他视图是活跃的。是否有其他方法可以激活所选视图?

感谢。

1 个答案:

答案 0 :(得分:0)

并没有很好地理解问题,但像打击这样的东西使得所有视图都可以用于平移手势。

// ---潘手势---

UIPanGestureRecognizer *panGesture =
[[UIPanGestureRecognizer alloc]
 initWithTarget:self
 action:@selector(handlePanGesture:)];

[backgndView addGestureRecognizer:panGesture];
[panGesture release]; 

panGesture =
[[UIPanGestureRecognizer alloc]
 initWithTarget:self
 action:@selector(handlePanGesture:)];
[frameView addGestureRecognizer:panGesture];
[panGesture release]; 

panGesture =
[[UIPanGestureRecognizer alloc]
 initWithTarget:self
 action:@selector(handlePanGesture:)];
[effectView addGestureRecognizer:panGesture];
[panGesture release]; 

panGesture =
[[UIPanGestureRecognizer alloc]
 initWithTarget:self
 action:@selector(handlePanGesture:)];
[itemView addGestureRecognizer:panGesture];
[panGesture release]; 

panGesture =
[[UIPanGestureRecognizer alloc]
 initWithTarget:self
 action:@selector(handlePanGesture:)];
[extraView addGestureRecognizer:panGesture];

[panGesture release];