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

  • Home
  • SEARCH
  • 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 8556641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:23:56+00:00 2026-06-11T15:23:56+00:00

Please, I need some help with some UILabels that must hold dynamic content. They

  • 0

Please, I need some help with some UILabels that must hold dynamic content. They are contained in a UIScrollView.

I can’t get them to resize properly depending on screen orientation. I also want to keep an exact distance between them.
Right now, I’m having trouble with 2 of them (many to come).

I’m using the following code to resize them but it doesn’t get me the expected results:

    - (void) updateLabelsPositionForPortrait
{
    summary_PersonalMonth.numberOfLines = 0;
    summary_PersonalDay.numberOfLines = 0;

    summary_PersonalMonth.frame = CGRectMake(summary_PersonalMonth.frame.origin.x,
                                             summary_PersonalMonth.frame.origin.y,
                                             summary_PersonalMonth.frame.size.width + 15,
                                             summary_PersonalMonth.frame.size.height);
    [summary_PersonalMonth sizeToFit];

    summary_PersonalDay.frame = CGRectMake(summary_PersonalDay.frame.origin.x,
                                           summary_PersonalDay.frame.origin.y + summary_PersonalMonth.bounds.origin.y + 10,
                                           summary_PersonalDay.frame.size.width + 15,
                                           summary_PersonalDay.frame.size.height);
    [summary_PersonalDay sizeToFit];

    [self updateScrollViewContentSize];
}

- (void) updateLabelsPositionForLandscape
{
    summary_PersonalMonth.numberOfLines = 1;
    summary_PersonalDay.numberOfLines = 1;

    summary_PersonalMonth.frame = CGRectMake(summary_PersonalMonth.frame.origin.x,
                                             summary_PersonalMonth.frame.origin.y,
                                             summary_PersonalMonth.frame.size.width,
                                             summary_PersonalMonth.frame.size.height);
    [summary_PersonalMonth sizeToFit];

    summary_PersonalDay.frame = CGRectMake(summary_PersonalDay.frame.origin.x,
                                           summary_PersonalDay.frame.origin.y - summary_PersonalMonth.bounds.origin.y - 10,
                                           summary_PersonalDay.frame.size.width,
                                           summary_PersonalDay.frame.size.height);
    [summary_PersonalDay sizeToFit];

}

and I call each method in shouldAutorotateToInterfaceOrientation: in the corresponding orientation.

if (UIInterfaceOrientationIsPortrait([UIDevice currentDevice].orientation))
{
    [self updateLabelsPositionForPortrait];
}
else
{
    [self updateLabelsPositionForLandscape];
}

The results are these:

  • Initial result on view load

Initial result on view load

  • Result after rotation in Landscape

Result after rotation in Landscape

  • Result after rotating back to portrait

Result after rotating back to portrait

Please, I need advice !

Thank you !

  • 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-11T15:23:57+00:00Added an answer on June 11, 2026 at 3:23 pm

    Store all labels starting form first to last in position in NSArray.

    Now making one function which set frames of labels according to orientation:

    -(void)setFramesOfLabel:(BOOL)flag
    {
        if(flag) //portrait
        {
          int height = 20;
          int spaceBetweenLabels = 20;
          itn xspace = 20 //
        }
        else//landscape changes
        {
          int height = 20;
          int spaceBetweenLabels = 20;
          itn xspace = 20 /
        }
        int count = 0;
        for(UILabel *label in arrLabels)
        {
           NSString *strText = [arrTexts objectAtIndex:count]; //as u may having text array to fill in labels as i assume
           CGSize expectedLabelSize = [strText sizeWithFont:label.font constrainedToSize:maximumLabelSize lineBreakMode:UILineBreakModeWordWrap]; //
    
           CGrect *newFrame = CGRectMake(xspace,height,expectedLabelSize.width,expectedLabelSize.height);
           [label setFrame:newFrame];
    
            height += expectedLabelSize.height;
           count ++;
        }
        [scrollView setContentSize(scrollView.width,height)];
    }
    

    Use

    if (UIInterfaceOrientationIsPortrait([UIDevice currentDevice].orientation))
    {
      [self setFramesOfLabel:TRUE];
    }
    else
    {    
      [self setFramesOfLabel:FALSE];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some help with this please I can't get a handle on it.
i need some help writing a for-loop please but i can't get it. i
I need some help to get this right, please. I have created an iPad
please i need you help with my script.. I'm trying to echo some content
Having some issue with Threadpooling here that I need some help with please. I
i am new at programming and i need some help with that please =/
I need some help with a regular expression, please help if you can I
I need some help! Please. I am trying to develop a very very simple
I need some help with a LINQ query in VB.Net, please. I have this
Need some help, please. I have a line of horizontal thumbnails loaded as ONE

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.