【问题标题】:Changing locationinview UITouch更改位置inview UITouch
【发布时间】: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;

【问题讨论】:

    标签: ios xcode uitouch


    【解决方案1】:

    uiimage-detecting-touch-and-dragging

    这可能会有所帮助..!!

    【讨论】:

      猜你喜欢
      • 2018-02-10
      • 2013-05-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多