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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:31:52+00:00 2026-06-18T01:31:52+00:00

I have create a labels with in the scroll view. The for loop count

  • 0

I have create a labels with in the scroll view. The for loop count is more than 1000. At the time the scroll is very slow. If the data is less amount (200, 300, …) at the time its scroll smoothly. I am using the below code for create label.

UILabel     *modelLabel;
UIButton    *modelButton;

for (int i = 0; i < [modelArray count]; i++)
{
    modelButton                 = [UIButton buttonWithType:UIButtonTypeCustom];
    modelButton.frame           = CGRectMake(0.0, (i * LABEL_HEIGHT), LABEL_WIDTH, LABEL_HEIGHT);
    modelButton.tag             = i+100;
    [modelButton addTarget:nil action:@selector(modelButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    [modelScrollView addSubview:modelButton];
    modelLabel                  = [[UILabel alloc] initWithFrame:CGRectMake(0.0, (i * LABEL_HEIGHT), LABEL_WIDTH, LABEL_HEIGHT)];
    modelLabel.text             = [NSString stringWithFormat:@"%@", [[modelArray objectAtIndex:i] valueForKey:@"Model"]];
    modelLabel.tag              = i+1000;
    modelLabel.backgroundColor  = [UIColor clearColor];
    modelLabel.textColor     = [UIColor grayColor];
    modelLabel.alpha         = 0.5;
    modelLabel.textAlignment    = UITextAlignmentCenter;
    modelLabel.font             = EUROSLITE_FONT(14);
    [modelScrollView addSubview:modelLabel];
}

[modelScrollView setContentSize:CGSizeMake(280.0, ([modelArray count] * LABEL_HEIGHT))];

How can I fix this issue?

Thanks in advance.

  • 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-18T01:31:53+00:00Added an answer on June 18, 2026 at 1:31 am

    This happens to you because you load to many things to the memory

    As the comment above said, It will be very easy to achieve using UITableView.

    Although if you want more control, and you decide using scroll view you have to implement lazy loding. This is being done be allocating and placing the labels when it actually needed to be showen and not during the initialization. You will be able to know that by setting you view controller as the delegate and get the contentOffset from the scrollViewDidScroll: method. Also after recognizing you’ll need te remove the subview in order to clear the memory

    You can see good example for it here

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

Sidebar

Related Questions

I have two little problems with my UIScrollView. I managed to create scroll view,
i have this crazy label for each time i create a migration that use
I'm trying to create a view that's full of controls (buttons, text views, labels,
I have a scroll view that I would like to fill the whole screen,
I have to show around 100pages in a scroll view and each page contains
I want to create labels in MFC (Static text) that have both bold and
I'm trying to create a View dynamically (on click). Any person have any idea
I have a view with a scrollview. I use code to add labels to
I have a two column TableLayout as the only child of a scroll view.
I have to create variable number of Labels and next to them TextBox controls

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.