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

The Archive Base Latest Questions

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

I have an UIScrollview that is zoomable, the subview is one UIView (viewTexto) that

  • 0

I have an UIScrollview that is zoomable, the subview is one UIView (viewTexto) that contains an UILabel inside (messageLabel).

This is the code

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollViewtmp{

    return viewTexto;
}
-(void)scrollViewDidEndZooming:(UIScrollView *)scrollViewtmp withView:(UIView *)view atScale:(float)scale{

        messageLabel.contentScaleFactor=scale;

    [scrollView setContentSize:CGSizeMake(scrollView.frame.size.width, messageLabel.frame.origin.y + messageLabel.frame.size.heightt)];

    }

With this code I can zoom, and the text is not blurry, there is no horizontal scroll but the size of the UILabel continues to be too large, so it is cut. I need that the width of the UILabel adopts to the scrollView width again as at the beginning.

I have read any question about UIScrollViews in SO and having found exactly what I need.

  • 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:59:10+00:00Added an answer on June 14, 2026 at 7:59 pm

    OK, so finally I found the answer as Ismael suggested I had to adjust the width, the problem was to find the equation.

    The way the scaling works and the width of the scrollview’s subviews is not obvious at the beginning.

    Once you scale a UIView in a scrollview, and you want to have the same width for it, you have to divide the width of the element by the scale.

    That is to say that if your initial width was 600, once you scale you can think that the width has changed and you only have to resize it again to 600, but it is not true. 600 is going to be multiplied by the scale automatically. So the right answer would be to resize it to 600 / scale.
    Here we divide.

    Now the code:

    Everything happens in the method:

    -(void)scrollViewDidEndZooming:(UIScrollView *)scrollViewtmp withView:(UIView *)view atScale:(float)scale{}
    

    The first thing was to get rid of the blurry fonts:

     messageLabel.contentScaleFactor=scale;
    

    In another method I saved the initial width of the UILabel messageLabel (inside scrollview), I called the variable “initialWidth”, that was 600. This is important, because I started using the current messageLabel width once in the scrollViewDidEndZooming method.

    To readjust the width of the subviews of the scrollview to 600, we only have to divide the initial width by the zoomscale, and readjust the label:

    [messageLabel setFrame:CGRectMake(0,0,(initialWidth/scale), messageLabel.frame.size.height)];
    [messageLabel sizeToFit];
    

    At this point, we have a scrollview that can be zoomed, with a Label that readjust the text to the initial width of the scrollview, we don’t have horizontal scrollbars, but we have a problem, the vertical scrollbars have a wrong height: we can only scroll a part of the text.

    This was a difficult second problem to solve.
    If you pass the messageLabel height to the contentsize, curiously it seems that it doesn’work, and even if I get a height multiplied by the scale in my NSLogs, it does not change the height of the scrolling, as if internally it was divided again. For example, if the initial height was 500, after scaling by 2, I get 1000 height, if I pass this value to the ContentSize it remains the same, as if it was divided again by 2.

    So the solution was this time to multiply by the scale.

    We only have to add this line:

       [scrollView setContentSize:CGSizeMake(scrollView.frame.size.width, (messageLabel.frame.origin.y+messageLabel.frame.size.height)*scale)];
    

    As it is seen, the difficult part was to understand this mess with dividing or multiplying by the scale.

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

Sidebar

Related Questions

I have a UIScrollView that contains a UIView inside. The UIScrollView has paging enabled
I have a UIScrollView that contains a custom UIView. In my UIView I am
I have a zooming UIScrollView that contains a UIView which contains some custom UIViews
I have a UIView inside of a UIScrollView that I want to resize. I
I want to have a UIScrollView that is inside of my UIAlertView . Code
I have a UIScrollView that contains an image and a segmented control that allows
I have a UIScrollView that contains multiple UITableViews horizontally - all of which are
I have a UIScrollView that contains a UITextView (not editable). I can't make the
I have a UIScrollView subclass that I am programmatically scrolling using UIView animations. I'd
I have a UIScrollView that contains a bunch of views: for(NSDictionary* deal in deals)

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.