繁体   English   中英

尝试在UIPanGestureRecognizer上移动UIImageView

[英]Trying to move UIImageView on UIPanGestureRecognizer

嗨,大家好,我正在尝试使用UIPanGestureRecognizer上的以下代码移动UIImageView

 CGPoint pointMove;
 pointMove.x = holderView.center.x + (currentPoint.x - lastPoint.x);
 pointMove.y = holderView.center.y + (currentPoint.y - lastPoint.y);

 holderView.center = pointMove;

 lastPoint = currentPoint;

但是,这给移动不顺畅带来了混乱。 请帮我

我有一个使用UIPanGestureRecognizer拖动图像的最佳示例

请下载此演示并检查它:-

https://github.com/elc/iCodeBlogDemoPhotoBoard

希望对你有帮助

这是一些相同的问题,请访问链接:-

使用UIPanGestureRecognizer触摸拖动+旋转偏离轨道

使用平移手势交换图像

如何使用UIPanGestureRecognizer移动对象? iPhone / iPad

尝试在您的代码中更改它。

  CGPoint translation = [gestureRecognizer translationInView:[holderView superview]];

    [holderView setCenter:CGPointMake([piece center].x + translation.x, [piece center].y + translation.y)];

我希望这能解决您的问题

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM