Let's say you have a typical model of scrolling through a table, and tapping an item to see details about it. My "detail" XIB has a label on it, and the controller is linked to the label properly (as an outlet). When is the correct time to set that label to whatever detail I want to show?
For example:
This doesn't work. But if I move the pdc.headerText.text line AFTER I push the view controller on the stack, it works.
Is this the wrong place to be setting labels & other items on the PersonDetail page? I could use viewDidAppear but how would it grab the data? Is it better to just do something here like pdc.statusDetail = @"some message" (NSString *statusDetail) and then on the PDC viewDidLoad method, set the headerText.text = statusDetail?
EDIT: Ah, even better maybe: pdc.person = person. Then the PersonDetailController has the entire Person data so it can print out the info in the viewDidLoad method...yes?
For example:
Code:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
PersonDetailController *pdc = [[PersonDetailController alloc]
initWithNibName:@"PersonDetail" bundle:nil];
Person *person = [people objectAtIndex:[indexPath row]];
pdc.title = person.name;
pdc.headerText.text = [NSString stringWithFormat:@"%@ is %@.", person.name, person.character]; //headerText is a UILabel on the PersonDetail XIB
GradientCellsAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
[delegate.navController pushViewController:pdc animated:YES];
[pdc release];
}
This doesn't work. But if I move the pdc.headerText.text line AFTER I push the view controller on the stack, it works.
Is this the wrong place to be setting labels & other items on the PersonDetail page? I could use viewDidAppear but how would it grab the data? Is it better to just do something here like pdc.statusDetail = @"some message" (NSString *statusDetail) and then on the PDC viewDidLoad method, set the headerText.text = statusDetail?
EDIT: Ah, even better maybe: pdc.person = person. Then the PersonDetailController has the entire Person data so it can print out the info in the viewDidLoad method...yes?