UIImageView in UIScrollView: panning fail?

Up vote 0 down vote favorite share g+ share fb share tw.

I am making a simple photo viewer that allows zooming and panning. So in IB I create a UIScrollView containing a UIImageView: Then I can configure it to house the photo as soon as the photo is available: - (void) imageCaptureCompleted { { UIImage* I = self.frontCamView. StillImage; self.imageView.

Bounds = CGRectMake(0, 0, I.size. Width, I.size. Height ); self.imageView.

Image = I; // - - - self.scrollView. MaximumZoomScale = 4.0; self.scrollView. MinimumZoomScale = 0.75; self.scrollView.

ClipsToBounds = YES; self.scrollView. Delegate = self; self.scrollView. ContentSize = self.imageView.bounds.

Size; } self hideCaptureView; UIImageWriteToSavedPhotosAlbum( self.frontCamView. StillImage, self, @selector( image: didFinishSavingWithError: contextInfo: ), nil ); } - (UIView *) viewForZoomingInScrollView: (UIScrollView *) scrollView { return self. ImageView; } This is almost working.

It is indeed letting me pan and zoom. However, it pans too far! It should bounce back when it hits the right edge of the photo.

But instead it behaves as if the photo is in a larger black rectangle. I have set up the autoresizing masks of the scroll view in exactly the same way as per the above picture. How to get it to work?

PS I have now figured this out; I will put up the answer for posterity. Ios uiscrollview uiimageview camera pan link|improve this question asked Nov 18 '11 at 13:17P I 2,4501246 56% accept rate.

This code sorts it out: // self.imageView. Bounds = CGRectMake(0, 0, I.size. Width, I.size.

Height ); self.imageView. Image = I; self. ImageView sizeToFit; However, I can't understand why this change is necessary.

If anyone can tell me, I will accept that answer ( in which case please paste the above code then I can remove this answer ).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions