How do you forcibly cancel a zooming open pinch gesture on a UIScrollView
, say when the user has zoomed "sufficiently" far to trigger a new action?
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
- “Zero out” sensitive String data in Swift
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- xcode 4 garbage collection removed?
- Unable to process app at this time due to a genera
- Swift - hide pickerView after value selected
- How can I add media attachments to my push notific
A brute force solution i found is to remove and re-add the view that receives the touches, as my (sub)scrollview just did not end reacting to zooms as long as the user would not end the gesture.
In ScrollViews this is done commonly if you remove / add subviews as the user scrolls through a large content size, so there is not even the need to write additional code.
To prevent user-controller zooming and panning but still allow programmatic zooming and panning of a scrollview, the best approach is to override the
UIScrollView's
-addGestureRecognizer
: method in a subclass.Each gesture recognizer is simply disabled, for finer control (for ex. allowing the pan control but only allow zooming via a double tap for instance) you'd simply check the incoming gesture recognizer via
-isKindOfClass:
and disabling as appropriate.Hope this helps.
How's this:
Just register this
selector(handlePinchGesture:)
with the gesture recognizer. This will make a sort of "one-shot" pinch handler which stops when it reaches either the upper or lower threshold.