开发者

touchesMoved out of the self view

开发者 https://www.devze.com 2023-03-15 19:33 出处:网络
I\'m working on an important project at my job place, and having a problem which I\'m stack with: I have 2 views in a line (1 scroll view w开发者_开发技巧ith images, and the other is just a UIImageVi

I'm working on an important project at my job place, and having a problem which I'm stack with:

I have 2 views in a line (1 scroll view w开发者_开发技巧ith images, and the other is just a UIImageView), I would like to make it able to move an image from the scroll view into the UIImageView), I could successfully recognize and move the image from the scrollView, but the problem is when the movement goes out of the scrollView the image dropped disappears behind and could not reach the road to the imageView.

any suggestions please?


Create a subclass of a UIView and display the image on this view. Then implement the methods touchesDidBegin, touchesMoved, touchesCancelled on this subclass. Use this new UIView in your scrollview for the images you want to drag, and make sure the scrollview.clipsToBounds = NO.

In touchesMoved, adjust the position of the view's frame and when touchesEnd, get the position of the frame to determine if it's in the other view.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号