【发布时间】:2011-07-06 10:02:23
【问题描述】:
我正在使用下面的代码在屏幕上拖动图像。我喜欢改变的一件事是图像的位置。现在,每次触摸都会改变位置,所以每次我尝试移动它时,它都会转化为我的手指。我怎样才能使它可以相对于我的手指移动?例如如果图像位于屏幕中间,并且我将手指放在屏幕的右下角,则图像不会转换为我的手指。希望这是有道理的。提前致谢。
// get touch event
UITouch *touch = [[event allTouches] anyObject];
// get the touch location
CGPoint touchLocation = [touch locationInView:touch.view];
// move the image view
image.center = touchLocation;
【问题讨论】: