是否有一个类/方法来处理拖动视图?
我发现了 有用的教程开始了解 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许您正在寻找 UIScrollView
Maybe you are looking for UIScrollView