0

I have UIScrollView. I should show small image first, and big image , when I zoom image. If I use this code, everything is OK:

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollViewCalled
{
    ImageScrollView *scroll = scrollViewCalled
    UIImageView *imageView = (UIImageView *)[scroll viewWithTag:kImageViewTag];
    return imageView;
}

The size of ImageView = the size of image (if image is small, it meens, that = the size of small image, if image is big - the size of big image) ContentSize of scrollView = size of imageView.

- (void)scrollViewDidEndZooming:(UIScrollView *)scrollViewCalled withView:(UIView *)view atScale:(float)scale
{
    ImageScrollView *scroll = scrollViewCalled
        UIImageView *imageView = (UIImageView *)[scroll viewWithTag:kImageViewTag];
    if ([self isBigImage:imageView])
    {
        return;
    }
    [self loadBigImage];
}

But if use this code (when I try to zoom, the big image is shown, but I see its maximum zoom scale, and I can't scroll to see the rest part of the image. But when I zoom one more time instead of scrolling the image, it begins to work properly and I finally can scroll the image. But I should zoom 2 times for that):

- (void)scrollViewWillBeginZooming:(UIScrollView *)scrollViewCalled withView:(UIView *)view
{
    ImageScrollView *scroll = scrollViewCalled
            UIImageView *imageView = (UIImageView *)[scroll viewWithTag:kImageViewTag];
        if ([self isBigImage:imageView])
        {
            return;
        }
        [self loadBigImage];
}

Why doesn't it work properly for scrollViewWillBeginZooming? I need to set big image before zooming, but not after.

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Paul T.
  • 4,938
  • 7
  • 45
  • 93
  • It looks like you might be in a situation where CATiled Layer is a much better way to adapt your image to different zoom scales. Look in the documentation for it and also some of the provided examples do a pretty good job showing you how to use it. – Dancreek Jun 26 '12 at 13:43
  • No, I can't split image into tiles, because I use encryption, and it takes 1 mitute to split one image and encrypt data for 1 image. It's too much for my application. – Paul T. Jun 27 '12 at 05:42

0 Answers0