iPhone“ touchesBegan”和“ touchesMoved”信息...不要移到触摸中心 [英] iPhone "touchesBegan" and "touchesMoved" message ... do not move to centre of touch

查看:54
本文介绍了iPhone“ touchesBegan”和“ touchesMoved”信息...不要移到触摸中心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从Apple网站上修改 MoveMe示例。当我的控制器收到 touchesMoved消息时,由于(伪代码)object.center = touch.center,它会将要移动的对象移动到触摸的中心。如何存储初始触摸的偏移量,以便在将触摸/拖动到一侧时将其拖到一边时手指会停留在该位置上?

I am modifying the "MoveMe" example from the apple web site. When my controller gets the "touchesMoved" message it moves the object being moved to the centre of the touch, because (pseudocode) object.center = touch.center. How can I store the offset of the initial touch so that if I start the touch/drag to the side my finger will stay on that spot while I drag it around?

推荐答案

当touchBegan消息到达时,您可以将target_view.frame存储在实例变量中。

You can store target_view.frame in an instance variable when touchBegan message arrives.

这篇关于iPhone“ touchesBegan”和“ touchesMoved”信息...不要移到触摸中心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆