0
votes

I have a image in UIScrollView, I wants user cannot scroll image in zoom time, I read many property of UIScrollView, but I am confused.

How we stop scrolling image(horizontally or vertically) when user zoom the image in scrollView.

I already test

 scroll.scrollEnabled=NO;

 scroll.directionalLockEnabled = YES;

 scroll.bounces=NO;

scroll.scrollEnabled = N0; stop scrolling but the task is that the user cannot scroll the image ,when user zoom the image , I need help

Thanks

1

1 Answers

0
votes

You have to set your viewcontroller as scrollviews delegate. Assuming you have UIImageView that you are zooming in scrollView. What you want to do is to center it in the middle of scrollviews bounds while zooming. If you only want to disable scrolling in vertical or horizontal direction then change only x or y center of imageView

- (void)scrollViewDidZoom:(UIScrollView *)scrollView
 {
  self.imageView.center=CGPointMake(CGRectGetMidX(self.scrollView.bounds), CGRectGetMidY(self.scrollView.bounds));
 }

I highly recommend having a look at apple video session on advanced scrollview techniques 2010, 2011 and 2012 they really explain quite well what a powerful beast UIScrollView really is. Hope this was helpful