0

I want to have a larger frame than an image so i do something like this: enter image description here

And of course i have UIScrollViewDelegate and i handle the zooming. But there is one problem. When i zoom picture i can scroll to this "blue" empty space in a zoom mode.

After zoom when my zoom picture width is greater than scrollView width i wish that user cannot scroll to this empty space. How can i achieve that?

(1) zoomScale 1.0:

enter image description here

(2) after zoom and move to edge:

enter image description here

(3) what i want it to be:

enter image description here

EDIT: After setting contentInset:

[self.scView setContentInset:UIEdgeInsetsMake(0, -30, 0, -(self.frame.size.width-csc.width/2))];

Why it is moving to left?

enter image description here

Jakub
  • 13,712
  • 17
  • 82
  • 139

1 Answers1

0

There might be a simpler approach, but one way that works is to use a negative contentInset (UIEdgeInsets) to the scrollView.

Jason Huh
  • 147
  • 2
  • 2
  • I set it: `[self.scView setContentInset:UIEdgeInsetsMake(0, -100, 0, -100)];` for `image.size.width = 120`, so it should be 320 full screen App, but it is not working. – Jakub Nov 08 '12 at 15:22
  • Thats odd.. when i try to do this only on one side (` [self.scView setContentInset:UIEdgeInsetsMake(0, 0, 0, -(self.frame.size.width-csc.width/2))];` it works only for this one side. But when i try it on second parameters it moved image (screen in Q). – Jakub Nov 08 '12 at 15:33