-1

I have an UIScrollView with many buttons and some labels. My question is: How can I easily zoom UIScrollView content (with two fingers)? Thank you very much.

2 Answers 2

2

UIScrollViews already support zoom using pinch gesture, you just need to implement the delegate method

- (UIView*)viewForZoomingInScrollView:(UIScrollView *)scrollView {
    // Return the view that you want to zoom
    return self.viewZoom;
}

Returning the view you want to zoom.

0

As Andrea pointed out the UIScrollView already supports zoom feature. Follow these steps:

  1. Add a UIView (say viewZoom) to the scrollView by giving same width and height as that of scroll view.
  2. Add all UI components (Buttons etc) to viewZoom.
  3. Set maximumZoomScale property of scroll view to '2' (or any other value as per your requirement).
  4. Set your view controller as delegate to ScrollView(scrollView.delegate = self).
  5. Implement - (UIView*)viewForZoomingInScrollView:(UIScrollView *)scrollViewin view controller and return the "viewZoom" you added to the scroll view from this method.
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.