拖放 UIScrollView 上的 UIImageView

发布于 2024-12-26 03:41:53 字数 194 浏览 2 评论 0原文

我很难找到 ios 拖放的好例子。我确实有一个可以拖放的工作代码,但它没有按预期工作。触摸并拖动后不会立即发生拖动。我必须触摸图像,将dragImage加载到主VC,然后修饰并拖动dragImage才能使其工作。

一些新添加的 UIImageView (dragImage) 在没有接收到初始 touchBegin 事件时,如何不接收触摸事件或拾取触摸事件。

I am having a hard time finding good example of drag and drop with ios. I do have a working code that does drag and drop but it is not working as expected. The drag does not happen immediately after the touch and drag. I have to touch the image, load a dragImage to the main VC and then retouch and drag the dragImage for it to work.

some how the new added UIImageView (dragImage) does not receive touch events or pick up touch events when it does not receive the initial touchBegin event.

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

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

发布评论

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

评论(1

孤云独去闲 2025-01-02 03:41:53

如果您使用 touchesBegan 作为处理拖/放的方式,这可能是第一个绊脚石。您可能会更轻松地使用 iOS 4.0 及更高版本中提供的各种 UIGestureRecognizers(除非您有支持 iOS 3 的特定原因)。

使用手势识别器,您只需将一个手势识别器附加到您的 UIImageView 上,并让视图将其中心点更改为每当触发识别器时触摸所在的位置。如果您不热衷于使用手势识别器,也许您可​​以提供一些现有代码,以便我们了解这里发生的情况。

If you're using touchesBegan as your way of handling drag/drop that might be the first stumbling block. It's probably going to be much easier for you to use the various UIGestureRecognizers that are provided in iOS 4.0 and greater (unless you have a specific reason for supporting iOS 3).

With gesture recognizers you can simply attach one to your UIImageView and have the view change its center point to where the touch is whenever your recognizer is triggered. If you're not keen on using gesture recognizers perhaps you could provide some of your existing code so we can get a feeling for what's going on here.

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