是否有一个类/方法来处理拖动视图?

发布于 2024-08-20 04:46:49 字数 570 浏览 5 评论 0原文

我发现了 有用的教程开始了解 Cocoa 如何处理触摸事件。我使用它作为基础来创建自定义脚本,我试图使 UIView 可拖动,与本机地图应用程序非常相似。

  • 我编写了一个自定义脚本,使用 TouchesBegan 方法将会 捕获输入开始的位置并 将其与中心点进行比较 UIView 使用一些条件 声明。
  • TouchesMoved 方法会做一些事情 进一步的条件语句 判断是否触摸启动 点和视图的中心将 积极或消极地移动。
  • 我也捕捉到了观点 边界,这样就不会走得太远 出去。

它缺乏其他应用程序(例如地图)或滚动 UITable 中的精美外观,例如用户松开手指后的缓动效果,以及到达边界时的可怕的捕捉效果。

有没有一种方法可以像这样获取视图并使其可拖动?如果没有的话我会继续完善我的剧本。

非常感谢!

I found a useful tutorial to get started in understanding how to Cocoa handles touch events. I've used this as a base to create a custom script, I'm trying to make a UIView draggable, very similar to the native Maps application.

  • I've written a custom script, using
    the touchesBegan method it will
    capture where the input began and
    compare it to the centre point of the
    UIView using some conditional
    statements.
  • The touchesMoved method will do some
    further conditional statements to
    determine whether the touch start
    point and the center of the view will
    move positively or negative.
  • I've also captured the views
    boundaries so it doesn't go too far
    out.

it's lacking the polished finished found in other applications such as Maps, or scrolling a UITable, such as the ease effect after the user has released their fingers, and the snapping effect when it reaches the boundaries is horrible.

Is there a method that takes a view and makes it draggable like this? If not I'll continue to refine my script.

Many thanks!

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

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

发布评论

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

评论(1

a√萤火虫的光℡ 2024-08-27 04:46:49

也许您正在寻找 UIScrollView

Maybe you are looking for UIScrollView

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