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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:41:53+00:00 2026-06-12T20:41:53+00:00

How do I reset the detail view in a master-detail view type app? For

  • 0

How do I reset the detail view in a master-detail view type app? For example, my master view simply lists names and when you select on a name, I want the details of that person you selected. Which the application will do. However, when I press the “back” button from the detail view and select another name, the detail view stays with the first selected item. How do I reset that detail view so it will show the details of whatever is selected?

I have this in my detailviewcontroller (Profile is a class):

-(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil title:(NSString *)name details:(Profile *)profile{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.title = NSLocalizedString(@"Detail", @"Detail");

        NSLog(@"Details: %@", [profile lastName]);
        _detailProfile = profile;

    }
    return self;
}

And this is in my masterviewcontroller:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (!self.detailViewController) {
        //self.detailViewController = [[MediaDirectoryDetailViewController alloc] initWithNibName:@"MediaDirectoryDetailViewController" bundle:nil];

        _showProfile = [_profileArray objectAtIndex:indexPath.row];

        self.detailViewController = [[MediaDirectoryDetailViewController alloc] initWithNibName:@"MediaDirectoryDetailViewController" bundle:nil title:@"Detail" details:_showProfile];
    }
    NSDate *object = _objects[indexPath.row];
    self.detailViewController.detailItem = object;
    [self.navigationController pushViewController:self.detailViewController animated:YES];
}

EDITED FROM THE ANSWER RECEIVED

Ok. detailProfile is a property of the detail view controller and I created a method:

@property (strong, nonatomic) Profile *detailProfile;
-(void)setDetailProfile:(Profile *)profile;

Implemented as follows:

-(void)setDetailProfile:(Profile *)profile{
    NSLog(@"Going to display profile: %@, %@", [profile lastName], [profile firstName]);

    [firstName setText:[profile firstName]];
    [lastName setText:[profile lastName]];
}

Which, now for whatever reason, my labels firstName and lastName are not being updated.

I did the following in the master:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (!self.detailViewController) {
        //self.detailViewController = [[MediaDirectoryDetailViewController alloc] initWithNibName:@"MediaDirectoryDetailViewController" bundle:nil];

        _showProfile = [_profileArray objectAtIndex:indexPath.row];

        NSLog(@"Profile selected last name: %@", [_showProfile lastName]);

       // self.detailViewController = [[MediaDirectoryDetailViewController alloc] initWithNibName:@"MediaDirectoryDetailViewController" bundle:nil title:@"Detail" details:_showProfile];

        self.detailViewController = [[MediaDirectoryDetailViewController alloc] initWithNibName:@"MediaDirectoryDetailViewController" bundle:nil title:@"Detail"];

        self.detailViewController.detailProfile = _showProfile;
    }
    NSDate *object = _objects[indexPath.row];
    self.detailViewController.detailItem = object;
    [self.navigationController pushViewController:self.detailViewController animated:YES];
}

My outputs to the log don’t update when a new items is selected – after going back from the detail view – and my labels are updating.

  • 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-12T20:41:55+00:00Added an answer on June 12, 2026 at 8:41 pm

    If detailProfile is not a property of the detail view controller, turn it into a property. Create your own setDetailProfile method and, in there, update anything in your detail controller (and on screen) that you need to when you get a new profile. (You don’t say where you’re doing that currently but probably you can move the code out of viewWillAppear or viewDidAppear or something.)

    Change your init method so that it doesn’t need a profile parameter and then change your master to something like:

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
        if (!self.detailViewController) {
            self.detailViewController = [[MediaDirectoryDetailViewController alloc] initWithNibName:@"MediaDirectoryDetailViewController" bundle:nil title:@"Detail"];
        }
        _showProfile = [_profileArray objectAtIndex:indexPath.row];
        self.detailViewController.detailProfile = _showProfile;
    
        NSDate *object = _objects[indexPath.row];
        self.detailViewController.detailItem = object;
        [self.navigationController pushViewController:self.detailViewController animated:YES];
    }
    

    EDIT:

    For an iPhone. because there’s no split view, ignore the part about creating a custom setDetailProfile method. Instead, set the property as show above, but then use self.detailProfile to update the screen during viewWillAppear:.

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

Sidebar

Related Questions

I have a classic master-detail scenario that I am implementing in backbone.js. For the
I'm creating a a Master-Detail Splitview app and I'm using a UIAlertView in the
Every time i reset & seed my database it wipes out the standard admin@example.com
I have a pretty basic app flow that is quite linear, so it fits
I have a NSURL request that brings back an array of name and phone,
I have an iPad SplitViewController application with the following features: master (left hand) view
[Category(SomeCat)] [Description(Gets or sets how items are displayed in the ShellListView control.)] [DefaultValue(View.Details)] new
I have an entity with several fields, but on one view i want to
Consider this code snippet that prompts the user to rate the app on the
- (void) hydrateDetailViewData { strong text//If the detail view is hydrated then do not

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.