How can enable zooming effect in UIScrollView?
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- how do you prevent page scroll in textarea on mobi
- Custom UITableview cell accessibility not working
相关文章
- UITableView dragging distance with UIRefreshContro
- Could I create “Call” button in HTML 5 IPhone appl
- Unable to process app at this time due to a genera
- How do you detect key up / key down events from a
- “Storyboard.storyboard” could not be opened
- Open iOS 11 Files app via URL Scheme or some other
- Can keyboard of type UIKeyboardTypeNamePhonePad be
- Can not export audiofiles via “open in:” from Voic
Make sure you set your viewController as the scrollViews delegate and implement:
Check tucan9389/ZoomableScrollView forked from huynguyencong/ImageScrollView.
Just create
ZoomableScrollView
and calldisplay(view:)
.DEMO
DEMO
Usage
Answer is here:
So:
UIScrollViewDelegate
and is set todelegate
on yourUIScrollView
instanceviewForZoomingInScrollView:
(which must return the content view you're interested in zooming). You can also implementscrollViewDidEndZooming:withView:atScale:
optionally.UIScrollView
instance, you have to set theminimumZoomScale
and themaximumZoomScale
to be different (they are 1.0 by default).Note: The interesting thing about this is what if you want to break zooming. Is it enough to return
nil
in theviewForZooming...
method? It does break zooming, but some of the gestures will be messed up (for two fingers). Therefore, to break zooming you should set the min and max zoom scale to 1.0.Have a read through this Ray Wenderlich tutorial:
http://www.raywenderlich.com/76436/use-uiscrollview-scroll-zoom-content-swift
If you follow through the section 'Scrolling and Zooming a Larger Image' it will get a image up and enable you to pinch and zoom.
In case the link gets altered, here's the main info: Put this code in your view controller (this sets the main functionality):
Add this to the class:
And then this if you want the double tap gesture to be recognised:
If you want more detail read the tutorial, but that pretty much covers it.
I don't think this is working for iOS 5.0 and Xcode 4.3+ Im looking for the same here, I found this its for images but it may help you.
http://www.youtube.com/watch?v=Ptm4St6ySEI
Have a look at this video
Description from video :
UIScrollViewDelegate
delegateUIScrollView