I'm new to iOS and I've been stuck for a while on this. My goal is to programmatically zoom to a specific spot when the user pinches anywhere in the view. This may seem strange, but it's an internal app not for the App Store. Right now, when I pinch to zoom, nothing happens.
On my View (it's a single view application), I have images that I'd like to zoom in on programmatically. Here's what I have done.
In the Interface Builder, I dragged a Scroll View object onto my View, and changed the size to fit the View
In the Scroll View, I set the minimum zoom = 0 and the maximum zoom = 1000 (just to make sure this wasn't the problem)
I dragged a Pinch Gesture Recognizer on top of the UIScrollView.
I right-clicked the UIGestureRecognizer, and created an action called handlePinch() where I placed my code to programmatically zoom when the pinch was recognized.
Implemented the zoom in handlePinch (shown below)
- (IBAction)handlePinch:(UIPinchGestureRecognizer *)sender { CGRect zoomRect; zoomRect.origin.x = 500; zoomRect.origin.y = 500; zoomRect.size.width = 512; zoomRect.size.height = 384; [scrollView zoomToRect:zoomRect animated:YES ]; }
Known: - The pinch gesture is being recognized, and handlePinch is being called
Thank you for any answers or suggestions in advance!