0

I have got a UIScrollView with a UIImageView as subview. The contentSize of the ScrollView has been set to the size of the UIImageView. I implemented zooming and scrolling of the UIImageView.

I need the UIScrollView to keep the scroll rect when I change its frame (proportionally).

How is this done?

My problem is, whenever I change the frame of the UIScrollView the visible rect of the UIImageView changes.

Thanks!

akw
  • 2,090
  • 1
  • 15
  • 21

1 Answers1

0

If I understand your problem correctly, you want to shrink the frame of the scroll view without changing what you are able to see inside of the scroll view. You can do this in the following way:

Create a new UIView and set its frame to the position and size that you want to see the content of the scroll view. Turn on the clips to bounds on that view, view.clipsToBounds = yes. Add the scroll view as a subview to the view you created. [view addSubview:scrollview]. Turn clips to bounds off on the scrollview, scrollview.clipsToBounds = no.

Hope that helps.

Kris Gellci
  • 9,539
  • 6
  • 40
  • 47
  • Hi Kris, thanks but this does not work for me. This is what I did: 1) I subclassed a UIView and set its clipsToBounds property to yes. 2) I created a UIScrollView and added it as a subview to my subclass. (in viewDidLoad:) 3) I added an UIImageView to the ScrollView, did the delegate stuff for zooming 4) Animating the frame of my subclassed UIView (which also changes the bounds of the UIScrollView because of the autoresizingMask) makes the visible area of the image change. What is wrong??? – akw Dec 07 '12 at 19:44