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

发布于 2024-12-02 22:04:21 字数 577 浏览 2 评论 0原文

我开发的应用程序有很多视图,但是当我想使用平移手势移动某些视图(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 对手势有效,但对其他视图无效。还有其他方法可以使选定的视图处于活动状态吗?

谢谢。

I develop app that have many view but when i want to move certain view (backgndView) using pan gesture, the other view was moved. Seem my desired view not active. Here the code.

//---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]; 

I think extraView is active for gesture but not other view. Any other way to make selected view active?

thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

○闲身 2024-12-09 22:04:21

不太理解问题,但像打击这样的东西会使所有视图都针对平移手势活跃。

//---平移手势---

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]; 

Didnt understand problem well but something like blow makes all views active for pan gesture.

//---pan gesture---

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]; 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文