Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8878867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:48:59+00:00 2026-06-14T19:48:59+00:00

I’m trying to display a large and high quality zoomable image using CATiledLayer and

  • 0

I’m trying to display a large and high quality zoomable image using CATiledLayer and UIScrollView. My code is based on the iOS Large image downsizing sample code.

The hierarchy of my UIScrollView is like that :

  • UIScrollView
    • UIImageView : that represents the first thumbnail of the large image
    • Old TiledView
    • TiledView

I want that the image into the scrollview become movable.

I tried what I found on this StackOverflow topic and it works. But after the first zoom on the image, it becomes impossible to move the image. I don’t know why ?

Here is my code :

-(id)initWithFrame:(CGRect)frame image:(UIImage*)_image {
    if((self = [super initWithFrame:frame])) {      
    // Set up the UIScrollView
        // Piece of code

        self.canCancelContentTouches = NO;

        UIPanGestureRecognizer* panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(move:)];
        [panGesture setMinimumNumberOfTouches:1];
        [panGesture setMaximumNumberOfTouches:1];
        [panGesture setDelegate:self];
        [frontTiledView addGestureRecognizer:panGesture];
        frontTiledView.exclusiveTouch = YES;

        UIPanGestureRecognizer* panGesture2 = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(move:)];
        [panGesture2 setMinimumNumberOfTouches:1];
        [panGesture2 setMaximumNumberOfTouches:1];
        [panGesture2 setDelegate:self];
        [backgroundImageView addGestureRecognizer:panGesture2];
        backgroundImageView.exclusiveTouch = YES;

        UIPanGestureRecognizer* panGesture3 = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(move:)];
        [panGesture3 setMinimumNumberOfTouches:1];
        [panGesture3 setMaximumNumberOfTouches:1];
        [panGesture3 setDelegate:self];
        [backTiledView addGestureRecognizer:panGesture3];
        backTiledView.exclusiveTouch = YES;
    }
    return self;
}

- (void)move:(UIGestureRecognizer*)sender {
    CGPoint translatedPoint = [(UIPanGestureRecognizer*)sender translationInView:frontTiledView];

    if([(UIPanGestureRecognizer*)sender state] == UIGestureRecognizerStateBegan) {
        positionDeplacement = frontTiledView.center;
    }

    translatedPoint = CGPointMake(positionDeplacement.x+translatedPoint.x, positionDeplacement.y+translatedPoint.y);
    frontTiledView.center = translatedPoint;
    backTiledView.center = translatedPoint;
    backgroundImageView.center = translatedPoint;
}

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T19:49:00+00:00Added an answer on June 14, 2026 at 7:49 pm

    I found the solution to my problem. I just have to add again the gestures in the scrollViewDidEndZooming delegate method and it works like a charm :

    Here is my code :

    - (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale {
        // set the new scale factor for the TiledImageView
        imageScale *=scale;
        CGRect imageRect = CGRectMake(0.0f,0.0f,CGImageGetWidth(image.CGImage) * imageScale,CGImageGetHeight(image.CGImage) * imageScale);
    
        // Create a new TiledImageView based on new frame and scaling.
        frontTiledView = [[TiledImageView alloc] initWithFrame:imageRect image:image scale:imageScale]; 
        [self addSubview:frontTiledView];
        [frontTiledView release];
    
        if (imageRect.size.width < 320 || imageRect.size.height < 460)
            [self initGestures];
    }
    
    - (void)initGestures {
        self.canCancelContentTouches = NO;
        frontTiledView.exclusiveTouch = YES;
        backgroundImageView.exclusiveTouch = YES;
        backTiledView.exclusiveTouch = YES;
    
        UIPanGestureRecognizer* panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(move:)];
        [panGesture setMinimumNumberOfTouches:1];
        [panGesture setMaximumNumberOfTouches:1];
        [panGesture setDelegate:self];
        [frontTiledView addGestureRecognizer:panGesture];
    
        UIPanGestureRecognizer* panGesture2 = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(move:)];
        [panGesture2 setMinimumNumberOfTouches:1];
        [panGesture2 setMaximumNumberOfTouches:1];
        [panGesture2 setDelegate:self];
        [backgroundImageView addGestureRecognizer:panGesture2];
    
        UIPanGestureRecognizer* panGesture3 = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(move:)];
        [panGesture3 setMinimumNumberOfTouches:1];
        [panGesture3 setMaximumNumberOfTouches:1];
        [panGesture3 setDelegate:self];
        [backTiledView addGestureRecognizer:panGesture3];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am reading a book about Javascript and jQuery and using one of the
I have a small JavaScript validation script that validates inputs based on Regex. I
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.