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:
- Changed the MyCustomSubView.xib, added an UIScrollView with Custom Class MyCustomSubView (and an UIImageView on it like before)
- Changed my MyCustomSubView class to extend UIScrollView
- Changed my MyViewController to implement UIScrollViewDelegate
- set mySubView.delegate to self(the controller)
- implemented (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView and returned the UIImageView of the subview
- enabled user interaction on the imageview and on the uiscrollview
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?