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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:59:28+00:00 2026-06-11T09:59:28+00:00

During loadView I am creating 20 UIButton s that I would like to change

  • 0

During loadView I am creating 20 UIButtons that I would like to change the title text of depending on the state of a UIPageControl.

I have a pre-save plist that is loaded into a NSArray called arrChars on the event of the current page changing, I set the buttons titles to their relevant text title from the array. The code that does this is:

for (int i = 1; i < (ButtonsPerPage + 1); i++) {

    UIButton *uButton = (UIButton *)[self.view viewWithTag:i];

    if(iPage == 1) {
        iArrPos = (i - 1);
    } else {
        iArrPos = (iPage * ButtonsPerPage) + (i - 1);
    }

    [uButton setAlpha:0];

    NSLog(@"Trying: %d of %d", iArrPos, [self.arrChars count]);
    if (iArrPos >= [self.arrChars count]) {                    
        [uButton setTitle: @"" forState: UIControlStateNormal];
    } else {

        NSString *value = [[NSString alloc] initWithFormat:@"%@", [self.arrChars objectAtIndex:iArrPos]];
        NSLog(@"%@", value);

        [uButton setTitle: [[NSString stringWithFormat:@"%@", value]    forState: UIControlStateNormal];

        [value release];

        //////Have tried:
        //////[uButton setTitle: value forState: UIControlStateNormal];

        //////Have also tried:
        //////[uButton setTitle: [self.arrChars objectAtIndex:iArrPos] forState: UIControlStateNormal];

        //////Have also also tried:
        //////[uButton setTitle: [[self.arrChars objectAtIndex:iArrPos] autorelease] forState: UIControlStateNormal];
    }

    [uButton setAlpha:1];
}

When setting the Title of a button it does not appear to be autoreleasing the previous title and the allocation goes up and up. What am I doing wrong?

I have been told before that tracking things by allocations is a bad way to chase leaks because as far as I can see, the object is not leaking in Instruments but my total living allocations continue to climb until I get a memory warning. If there is a better way to track there I would love to know.

Update

Forgot to mention that instead of using the value I retrieve from my array I just set the title to @”Test” – it is fine and there is no endless increase every time I change the page.

  • 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-11T09:59:29+00:00Added an answer on June 11, 2026 at 9:59 am

    After many long nights I decided to bite the bullet and send this one into the Apple’s DTS.

    Although the response was useful, it was not what I had hoped. Within arrChar were occasionally glyphs that when loaded I am told do not get unloaded. Full explanation:

    As far as I know, iOS doesn’t unload the glyphs after they’ve been loaded into memory. That is why you see in Instrument.app the memory allocation rises when loading new characters, and keeps flat when you going back and forward later on. It is pretty much the design behavior of iOS that we can’t change anything. If you really want to control the memory usage, you may alternately make the characters as images and use UIImage (imageWithContentsOfFile:) to load and release.

    Hope this helps someone out there.

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

Sidebar

Related Questions

During the process of building software applications, you would start testing what you have
During the startup of a Linux AMI, I would like to download some data
During a recent peer review, another Software Engineer suggested that I state that the
I have a UIViewController that materializes its view in loadView (i.e. no nib). Per
During a typical day programming, I implement functions in a way that I would
I'm creating my view hierarchy programmatically in loadView in my ViewController. I have to
During conversion old, 2008 database project into 2010 database project using features like Partial
During PDf generation in Jasper, I have 2 bands having table in each, if
During exporting from an HTML text to an Excel sheet, I'm trying to preserve
During form processing I'd like to be able to set a foreign key field

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.