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 8857605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:37:53+00:00 2026-06-14T14:37:53+00:00

In my iPad app, Universal Combat Log (new-layout branch), I have a UIView subclass

  • 0

In my iPad app, Universal Combat Log (new-layout branch), I have a UIView subclass (UCLLineChartView) which contains a UIScrollView and the scrollview in turn contains another UIView subclass (ChartView). ChartView has multiple sub-layers, one for each line of data that has been added to the chart. UCLLineChartView draws the axes and markers. The contents of these views/layers are entirely custom drawn, no stock views are used (e.g. UIImageView).

I’m having a problem with zooming — it’s scaling the ChartView like an image, which makes the drawn line all blurred and stretched. I want the line to stay sharp, preferably even while the user is in the act of zooming, but after 3 days of hacking at this, I cannot get it to work.

If I override setTransform on the ChartView to grab the scale factor from the transform but don’t call [super setTransform], then the scrollview’s zoomScale stays at 1. I tried keeping the given transform and overriding the transform method to return it. I tried replicating the effects of setTransform by changing the ChartView’s center and bounds but I wasn’t able to get the behaviour quite right and it still didn’t seem to affect the scrollview’s zoomScale. It seems that the scrollview’s zoomScale depends on the effects of setTransform, but I cannot determine how.

Any assistance would be greatly appreciated.

  • 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-14T14:37:54+00:00Added an answer on June 14, 2026 at 2:37 pm

    I have figured out a solution to my problem that is not too gross a hack. In your UIScrollViewDelegate:

    - (void)scrollViewWillBeginZooming:(UIScrollView *)scrollView withView:(UIView *)view
    {
        [_contentView beginZoom];
    }
    
    - (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale
    {
        CGSize size = scrollView.bounds.size;
        CGPoint contentOffset = _scrollView.contentOffset;
    
        CGFloat newScale = _contentView.scale;
        newScale = MAX(newScale, kMinZoomScale);
        newScale = MIN(newScale, kMaxZoomScale);
    
        [_scrollView setZoomScale:1.0 animated:NO];
        _scrollView.minimumZoomScale = kMinZoomScale / newScale;
        _scrollView.maximumZoomScale = kMaxZoomScale / newScale;
    
        _contentView.scale = newScale;
    
        CGSize newContentSize = CGSizeMake(size.width * newScale, size.height);
    
        _contentView.frame = CGRectMake(0, 0, newContentSize.width, newContentSize.height);
        _scrollView.contentSize = newContentSize;
    
        [_scrollView setContentOffset:contentOffset animated:NO];
    
        [_contentView updateForNewSize];
        [_contentView setNeedsDisplay];
    }
    

    In your content view, declare a scale property and the following methods:

    - (void)beginZoom
    {
        _sizeAtZoomStart = CGSizeApplyAffineTransform(self.frame.size, CGAffineTransformMakeScale(1/self.scale, 1));
        _scaleAtZoomStart = self.scale;
    }
    
    - (void)setTransform:(CGAffineTransform)transform
    {
        self.scale = _scaleAtZoomStart * transform.a;
        self.frame = CGRectMake(0, 0, _sizeAtZoomStart.width * self.scale, _sizeAtZoomStart.height);
    
        [self updateForNewSize];
        [self setNeedsDisplay];
    }
    

    And if your content view uses sub-layers, you’ll need to disable their implicit animations by adding the following to the sub-layers’ delegate(s):

    - (id<CAAction>)actionForLayer:(CALayer *)layer forKey:(NSString *)event
    {
        // prevent animation of the individual layers so that zooming doesn't cause weird jitter
        return (id<CAAction>)[NSNull null];
    }
    

    The basic idea here is that the overridden setTransform uses the scale factor from the tranform matrix to calculate the new scale factor for the content view and then resizes the content view accordingly. The scrollview automatically adjusts the content offset to keep the content view centered.

    The scrollViewDidEndZooming code keeps the zooming bounded.

    There are further complexities for dealing with resizing the scrollview when rotating device for example.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a universal app which I decided should become iPad only from the
I have a Universal app (iPhone/iPad) which has an iAd displayed at the bottom
I have a Universal app (iPhone/iPad) which is very basic. There is a List
I have a Universal app (iPhone/iPad) testing on IOS4.3. It has an iAd which
I have an iPhone/iPad app which play a HTTP Live Stream of a tv
I have a iPhone/iPad app (universal binary) with a regular UIWebView that displays webpages
I'm building an app which is a universal iPhone/iPad app. I'd like to support
I have recently created a Universal App in Xcode 4 to build my new
I have a universal app and for each device (iPad, iPhone) have different sets
Im converting an Iphone app to a universal App, I have created an Ipad

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.