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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:20:24+00:00 2026-06-09T07:20:24+00:00

I’m working on a tabbed app that (among other things) creates a simple Facebook

  • 0

I’m working on a tabbed app that (among other things) creates a simple Facebook feed. The Facebook section is a UINavigationController holding a Master Table View and a Detail View. When I click one of the rows in the Master Table View, it brings up the detail view (and the appropriately filled labels) as intended. However, if I go back to the Master View and select another row, something strange happens. If the “detailLab” label (which is sizeToFit‘d) was, say, four lines long on the first occurrence of Detail View, and the “detailLab” label was 2 lines long on the second occurrence of Detail View, then on the second occurrence of Detail View, “detailLab” will display the first two lines properly, but underneath them will be the last two lines from the first occurrence of Detail View.

A picture of this happening.

And some (hopefully) relevant code:

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    CGRect labelFrame = CGRectMake(100, 40, 220, 150);
    detailLab = [[UILabel alloc] initWithFrame:labelFrame];
    [detailLab setTextColor:[UIColor darkGrayColor]];
    detailLab.font = [UIFont systemFontOfSize:14];

    [detailLab setText:detail];
    [detailLab setNumberOfLines:0];
    [detailLab sizeToFit];

    [self.view addSubview:detailLab];

    NSURL *url = [NSURL URLWithString:pictureString];
    NSData *imageData = [[NSData alloc] initWithContentsOfURL:url];
    picture = [UIImage imageWithData:imageData];
    bigImage.image = picture;
    NSLog(@"dateString: %@", dateString);
    dateLabel.text = dateString;
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    bigImage = nil;
    detailLab = nil;
    detailLab.hidden = YES;
    // Release any retained subviews of the main view.
    self.detailDescriptionLabel = nil;
}

If you need any other code or details, just ask; I’d be happy to provide it.

  • 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-09T07:20:25+00:00Added an answer on June 9, 2026 at 7:20 am

    The problem is that each time viewWillAppear is called you are creating a new label without, I assume, removing it in viewWillDisappear. So the labels are stacking up, one on top of the other.

    Remember you may get called like this (ignoring irrelevant calls):

    viewDidLoad
    
    viewWillAppear
    viewWillDisappear
    
    viewWillAppear        <- Whoops! Two labels
    viweWillDisappear
    
    viewDidUnload
    

    A neater solution would be to add your label view in viewDidLoad and only alter the position of that already existing view in viewWillAppear. You still need to remember to dispose of the view in viewDidUnLoad.

    Here’s what I mean (note this was only eyeball compiled so you may need to correct some typos):

    - (void)viewDidLoad
    {
        [super viewDidLoad];
        detailLab = [[UILabel alloc] initWithFrame:CGRectZero];
        [detailLab setTextColor:[UIColor darkGrayColor]];
        detailLab.font = [UIFont systemFontOfSize:14];
        [self.view addSubview:detailLab];
    }
    
    - (void)viewWillAppear:(BOOL)animated
    {
        [super viewWillAppear:animated];
        CGRect labelFrame = CGRectMake(100, 40, 220, 150);
        [detailLab setFrame:labelFrame];
        [detailLab setText:detail];
        [detailLab setNumberOfLines:0];
        [detailLab sizeToFit];
    
        NSURL *url = [NSURL URLWithString:pictureString];
        NSData *imageData = [[NSData alloc] initWithContentsOfURL:url];
        picture = [UIImage imageWithData:imageData];
        bigImage.image = picture;
        NSLog(@"dateString: %@", dateString);
        dateLabel.text = dateString;
    }
    
    - (void)viewDidUnload
    {
        [super viewDidUnload];
        bigImage = nil;
        detailLab = nil;
        detailLab.hidden = YES;
        // Release any retained subviews of the main view.
        self.detailDescriptionLabel = nil;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am doing a simple coin flipping experiment for class that involves flipping a
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I know there's a lot of other questions out there that deal with this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,

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.