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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:43:13+00:00 2026-05-12T09:43:13+00:00

I have a navController and tableViewController set up such that selecting a table row

  • 0

I have a navController and tableViewController set up such that selecting a table row will push a detail view on the navController’s stack and display detailed information about the row selected. In the detail view I use a single UILabel to display the info, and I set the value of the label’s text property in viewDidLoad of the detail view controller.

The first time I select a row, the detail view comes up with the expected text. When I go back to the table view and select a different row, the detail view comes up with the same text as the first time.

I have seen some code samples where the detail view controller is released and then set to nil after being pushed on the navController’s stack. If I add that to my code, the problem goes away, but I don’t understand why.

Can someone explain to me what’s going on here?

Thanks!

  • 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-05-12T09:43:14+00:00Added an answer on May 12, 2026 at 9:43 am

    -viewDidLoad is called only when the… well, when the view is loaded. That is to say, when it is created in memory, which is the first time you create the view controller. Any customizations based input data should be done in -viewWillAppear: instead, which gets called every time before you push it onto the navigation controller.

    Although, in general practice, I always release a new view controller immediately after pushing it onto the stack, since it doesn’t belong to me any more, it belongs to the navigation controller. In this case, the next time you push it on to the stack, it will load the view again, since it’s a new object.

    - (void) tableView:(TableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
        UIViewController *screen = [[MyNewViewController alloc] initWithData:[data objectAtIndex:indexPath.row]];
        [self.navigationController pushViewController:screen animated:YES];
        [screen release];
    }
    

    The main idea, though, is that customizing a view based on data that may change every time you see the view should be done within -viewWillAppear:. Customizing a view further than you can in Interface Builder, changing things which won’t change no matter what data you’re looking at, should be done in -viewDidLoad

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

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer With your code, an instance of D is an instance… May 12, 2026 at 7:22 pm
  • Editorial Team
    Editorial Team added an answer http://devpicayune.com/pycon2008/django_admin.html Once you have your models setup, Django's admin is… May 12, 2026 at 7:22 pm
  • Editorial Team
    Editorial Team added an answer Setting jsonReader : { repeatitems: false } in my jqGrid… May 12, 2026 at 7:22 pm

Related Questions

I have a movie file that does work. I added a tableview controller inside
I have a View that has a UIWebView, and an OptionsPane (Custom UIViewController with
I have a view that has a navigationController with two buttons, START (essentially a
I have a UINavigationController onto which I push a 'loading screen' UIViewController whilst I

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.