views:

21

answers:

1

I've got a UITableView with some records shown, once a row is selected another screen appears allowing the user to edit the record. They then click Done or Cancel on the navigation bar and return to the UITableView screen.

Heres my code in the didSelectRowAtIndexPath

if (self.transactionDetailViewController == nil ) { 
    TransactionDetailViewController *aBookDetail = [[[TransactionDetailViewController alloc] initWithNibName:@"TransactionDetailView" bundle:nil] autorelease];

    self.transactionDetailViewController = aBookDetail;
    [aBookDetail release];
} 

giRecToEdit = [[[transactionsArray objectAtIndex:indexPath.row] objectForKey:@"pid"] integerValue]; 

transactionDetailViewController.hidesBottomBarWhenPushed = YES;
BAppDelegate *delegate = (BAppDelegate *)[[UIApplication sharedApplication] delegate];
[delegate.billsndepsNavController pushViewController:transactionDetailViewController animated:YES];

At the moment I have my UITextFields populate code in the viewDidLoad method of TransactionDetailView, however this code only gets called once when the view is allocated.

I tried commenting out ...

if (self.transactionDetailViewController == nil ) {

Which worked for about three row selections then crashes the app.

So I must be using the wrong method, viewDidLoad isn't the right place to populate controls, so where should I put this code ?

+3  A: 

Use viewWillAppear:.

Ole Begemann