簡體   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