开发者

how to pinch image in iphone

开发者 https://www.devze.com 2022-12-29 15:17 出处:网络
Hi I am new i want to develop a application that we zoom in and zoom out image but i am not understand how 开发者_开发问答to do this. any one help me with code and otherFor iPhone OS 3.2 or higher, us

Hi I am new i want to develop a application that we zoom in and zoom out image but i am not understand how 开发者_开发问答to do this. any one help me with code and other


For iPhone OS 3.2 or higher, use the bundled gesture recogniser UIPinchGestureRecognizer.


In my opinion the easiest way would be to add an UIScrollView to your viewcontroller which will be the scrollviews delegate. Then you'll implement the viewForZoomingInScrollView UIScrollViewDelegate method where you'll return the UIImageview that has to be zoomed/pinched.

You would also need to set the maximumZoomScale and minimumZoomScale properties of the UIScrollView.

UIScrollView documentation UIScrollViewDelegate documentation


A scroll view also handles zooming and panning of content. As the user makes a pinch-in or pinch-out gesture, the scroll view adjusts the offset and the scale of the content. When the gesture ends, the object managing the content view should should update subviews of the content as necessary. (Note that the gesture can end and a finger could still be down.) While the gesture is in progress, the scroll view does not send any tracking calls to the subview.

The UIScrollView class can have a delegate that must adopt the UIScrollViewDelegate protocol. For zooming and panning to work, the delegate must implement both viewForZoomingInScrollView: and scrollViewDidEndZooming:withView:atScale:; in addition, the maximum (maximumZoomScale) and minimum ( minimumZoomScale) zoom scale must be different.

0

精彩评论

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

关注公众号