I am having some troubles making my UIScrollView
to exhibit both scrolling and zooming. My class (which sub-classes UIScrollView
) has a UIView
as a sub-view, and in this sub-view I draw on a CALayer
. As soon as the app launches, I can scroll the view, but as soon as I zoom using the pinch gesture, the scrolling feature stops working, and only the zoom works. My code:
bpmGraphView = [[UIView alloc] init];
//--- configure the scroll-view and add the graph-view as a subview
[self setZoomScale:1.0];
[self setContentSize:CGSizeMake(1000.0, 169.0)];
[self setMultipleTouchEnabled:YES];
[self setScrollEnabled:YES];
self.maximumZoomScale = 20.0;
self.minimumZoomScale = 0.05;
self.clipsToBounds = YES;
self.delegate = self; //--- set the scroll-view delegate to self
[self addSubview:bpmGraphView];
And the delegate method:
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView{
return [self bpmGraphView];
}
Any ideas?
EDIT
Some dimensions: My UIScrollView
is 320x169 and it is positioned 7 pixels to the right of the left edge of the screen. The (scrollable) UIView
inside it should have the same height, but start 30 pixels to the left of the UIScrollView
, and end somewhere far to the right - 1000 is just a test number. The sublayer I add to UIView
should have the same size and position as it's superview.
I will init the UIView
with the proper frame and report any changes in the behavior of the app.