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 63291

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T18:36:35+00:00 2026-05-10T18:36:35+00:00

I have an app where I create many uiviews and add them to the

  • 0

I have an app where I create many uiviews and add them to the self.view of the UIViewController. My app is running really slowly. I am releasing all of my objects and have no memory leaks (I ran the performance tool). Can anyone tell me what could be making my app so slow? (code is below)

[EDIT] The array has around 30 items. [/EndEdit]

Thanks so much!

Here is the code for the loadView method of my UIViewController:

- (void)loadView {      UIView *contentView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];     contentView.backgroundColor = [UIColor whiteColor];     self.view = contentView;     [contentView release];         int length = 0;     for(NSString *item in arrayTips)     {         length++;         [item release];     }     int index = 0;     for(NSString *item in arrayTitles)     {         SingleFlipView *backView = [[SingleFlipView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];            backView.userInteractionEnabled = YES;         backView.backgroundColor = [UIColor whiteColor];         [backView setViewIndex:index];         [backView setLastViewIndex:length];         CGRect labelFrame = CGRectMake(10.0f, 0.0f, 300.0f, 30.0f);         UILabel *backLabel = [[UILabel alloc] initWithFrame:labelFrame];         backLabel.textAlignment = UITextAlignmentCenter;         backLabel.userInteractionEnabled = YES;         backLabel.text = item;         backLabel.font = [UIFont fontWithName:@'Georgia' size:24.0f];         backLabel.textColor = [UIColor blackColor];         backLabel.backgroundColor = [UIColor whiteColor];          CGRect textFrame = CGRectMake(10.0f, 30.0f, 300.0f, 110.0f);         UITextView *tbxView = [[UITextView alloc] initWithFrame:textFrame];         tbxView.textAlignment = UITextAlignmentCenter;         tbxView.userInteractionEnabled = YES;         tbxView.editable = FALSE;         tbxView.text = [arrayTips objectAtIndex:index];         tbxView.font = [UIFont fontWithName:@'Arial' size:14.0f];         tbxView.textColor = [UIColor blackColor];         tbxView.backgroundColor = [UIColor whiteColor];          //CGRect labelFrame = CGRectMake(10.0f, 0.0f, 84.0f, 30.0f);         UIImage *nextTip = [[UIImage imageNamed:@'NextTip.png'] retain];         UIImageView *nextTipView = [ [ UIImageView alloc ] initWithImage:nextTip];         nextTipView.frame = CGRectMake(230.0f, -10.0f, 84.0f, 30.0f);         nextTipView.userInteractionEnabled = YES;           UIImageView *view = [[ UIImageView alloc ] init];         view.userInteractionEnabled = YES;         if(self.sexString == @'Men')         {             UIImage *imgTip = [[UIImage imageNamed:@'feet_small.jpg'] retain];             view.image = imgTip;             view.frame = CGRectMake(0.0f, 110.0f, 416.0f, 228.0f); //59*161             [imgTip release];         }          [backView addSubview:view];         [backView addSubview:tbxView];         [backView addSubview:backLabel];         //[backView addSubview:nextTipView];          [self.view addSubview:backView];         [backView release];         [backLabel release];         [nextTip release];         [nextTipView release];         [tbxView release];         [view release];          index++;          [item release];     }   } 
  • 0 0 Answers
  • 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. 2026-05-10T18:36:35+00:00Added an answer on May 10, 2026 at 6:36 pm

    Having deep view hierarchies can lead to slow downs that you can often fix through flattening them some with custom views, but if you are using simple views you can have dozens on the screen with no perceptible performance impact, so in general I recommend ignoring how many views you have when you are developing, and then reducing the view count if it proves to be a performance problem.

    Having said that, you appear to be setting up something with an unboundedily large number of views which is not good. Without knowing how many entries there are in array titles I can’t tell you what is going on exactly, but I suspect that while the actual visual heiarchy with each backView you are creating is fine, making a backView for each item in the array and using indices to have the front most one hide all the other ones behind it is causing you to have way too many views.

    So, how to test it:

    Add a break to the bottom of your for loop. Make the loop drop out after a single iteration and see if performance improves. If it does, then the huge view hierarchies are your issue. YOu may have to hack up the routine that changes the indexes to make sure it never swaps to an invalid index to test.

    If that is the case you have a few options. You could implement a custom view and flatten every backview into a single view, but depending on how many you have that mat not be sufficient, and it is more work than simply building the back views the way you currently are, but on demand instead of at load time:

    1) Refactor the code in your for loop into a separate method that makes a backView for a specific title and attaches it to the view at that time. 2) Where ever you are currently altering the indexes to make the backview visible, instead call the new method to actually build and attach the backview at that time

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

Sidebar

Ask A Question

Stats

  • Questions 59k
  • Answers 59k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer I think I understand the problem ... You can traverse… May 11, 2026 at 8:58 am
  • added an answer Not sure what you're asking, but most people write tests… May 11, 2026 at 8:58 am
  • added an answer There are portions of ANSI CL that leave certain details… May 11, 2026 at 8:58 am

Related Questions

I have an app where I create many uiviews and add them to the
I have an app where I want to link an instance of a model
Hey all - I have an app where I'm authenticating the user. They pass
I have an iphone app where I call these three functions in appDidFinishLaunching: glMatrixMode(GL_PROJECTION);
I have an interesting situation where I need to deploy an ASP.NET MVC app
I have an app that needs to open a new window (in the same
I have an app with a large ListView which is terribly slow so I'm
I have an app using PHP and the PayPal API. The basic way it
I have an app written in C# that lies on a network share. When
I have an app which could benefit from the user being able to choose

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.