Good evening!
I am trying to increase the UIScrollView, more specifically all the subviews placed inside.
As far as I understand, I need to implement the UIScrollViewDelegate method:
func viewForZoomingInScrollView(scrollView: UIScrollView) -> UIView? {
return subView
}
In my test projects, the increase just won't work until I do this. But using this technique, I can only increase (1) a single view. There are dozens of subviews in my scroll that I also want to increase. I can solve this by placing one UIView inside a UIScrollView and then other subviews inside this container view, but I would like to ask if there is a better solution?
I used both the automatic pinch mechanism to increase scrollview, and later played with my own recognizing gesture:
override func viewDidLoad() {
super.viewDidLoad()
...
let pinchGesture = UIPinchGestureRecognizer(target: self, action: "pinchHandler:")
scrollView.addGestureRecognizer(pinchGesture)
.
.
.
func pinchHandler(recognizer: UIPinchGestureRecognizer)
{
if recognizer.state == UIGestureRecognizerState.Began
{
if recognizer.scale < 1.0 {
scrollView.setZoomScale(1, animated: true)
} else {
scrollView.setZoomScale(2, animated: true)
}
}
}
1 ( viewForZoomingInScrollView)
.