Reputation: 3557
In general: I got a custom UIView with a xib file as subview on a UIViewController. I add the subview programmatically in my controller.
In my UIViewController:
NSArray *subviewArray = [[NSBundle mainBundle] loadNibNamed:@"MyCustomSubView" owner:self options:nil];
mySubView = [subviewArray objectAtIndex:0];
...
[self.view addSubview:mapView];
Because I need to scroll on this subview, which also have an UIImageView on it, I decided to change my custom UIView into an UIScrollView.
I did the following steps:
These were my total steps I think. But as example, the viewForZoomingInScrollView method wasn't called. Also I tried to zoom in, but nothing happened.
Anyone an idea, what could be wrong?
Upvotes: 1
Views: 800
Reputation: 11221
Looking briefly at the UIScrollView
Class Reference page, I see the following:
The UIScrollView class can have a delegate that must adopt the UIScrollViewDelegate protocol. For zooming and panning to work, the delegate must implement both viewForZoomingInScrollView: and scrollViewDidEndZooming:withView:atScale:; in addition, the maximum (maximumZoomScale) and minimum ( minimumZoomScale) zoom scale must be different.
You mentioned implementing viewForZoomingInScrollView:
, but not scrollViewDidEndZooming:atScale:
, nor did you mention setting maximumZoomScale
or minimumZoomScale
. Try doing those things, and check back if you're still having issues.
Upvotes: 2