0

I have several subviews added to a UIScrollview. Every thing works fine when swiping left and right, ie the subviews move with the swipe. When I use the pinch gestures the subviews do not zoom in and out with the other contents of the scrollview. Everything drawn in context works fine but the subviews remain the same size but move I think based on the movement of their origins, off screen for example if pinching out.

I am calling...

[scrollView setAutoresizesSubviews:YES];

on viewDidLoad. I have also called...

subView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeigh 

for each subview added.

What am I dong wrong, or is this not the way to do it?

user278859
  • 10,379
  • 12
  • 51
  • 74

1 Answers1

1

Have you declared the delegate functions to resize the view when it is called ?

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView;

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView;

- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale;
TheSquad
  • 7,385
  • 8
  • 40
  • 79
  • Actually the answer to your question is yes, but your answer pointed out the problem. I created the UIScrollView (bodyClockScrollView) with a in IB and added a UIView (bodyClock) to bodyClockScrollView all in IB. – user278859 Dec 26 '10 at 18:15
  • (continued) All the in context drawings are done in bodyClock. The problem was that I was adding the subviews to bodyClockScrollView and returning bodyClock in viewForZoomingInScrollView. If I add the subviews to bodyClock they all zoom correctly. – user278859 Dec 26 '10 at 18:23
  • (continued) Now I have a problem with touches. All of the subviews are supposed to respond to touches and they do when added to the scrollView, but they do not when added to bodyClock. Funny thing is that they do start responding after zooming in. I am pretty sure that this is a first responder issue but I am confused as to how to pass the touches on to the bodyClock. Thanks for any additional help. – user278859 Dec 26 '10 at 18:27
  • After trying many different approaches and searching here and on the net, I am going ask about this new problem in a separate question. – user278859 Dec 26 '10 at 21:39