首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >尝试在UIPanGestureRecognizer上移动UIImageView

尝试在UIPanGestureRecognizer上移动UIImageView
EN

Stack Overflow用户
提问于 2013-01-09 17:39:05
回答 2查看 3.8K关注 0票数 0

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

代码语言:javascript
运行
复制
 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;

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

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-01-09 17:53:14

尝试在您的代码中更改此设置。

代码语言:javascript
运行
复制
  CGPoint translation = [gestureRecognizer translationInView:[holderView superview]];

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

我希望这能解决你的问题

票数 1
EN

Stack Overflow用户

发布于 2013-01-09 17:51:07

我得到了一个使用UIPanGestureRecognizer拖动图像的最佳示例

请下载此演示并进行检查:

https://github.com/elc/iCodeBlogDemoPhotoBoard

希望是你的帮助

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

Drag + Rotation using UIPanGestureRecognizer touch getting off track

swapping images using pan gesture

How to use UIPanGestureRecognizer to move object? iPhone/iPad

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14232159

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档