iPhone “touchesBegan” and “touchesMoved” message … do not move to centre of touch

五迷三道 提交于 2020-01-16 16:15:39

问题


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?


回答1:


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




回答2:


Can't you store that in an instance variable of your class?



来源:https://stackoverflow.com/questions/2438504/iphone-touchesbegan-and-touchesmoved-message-do-not-move-to-centre-of-to

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!