开发者

iPhone, where should I put my control populate pushed view, viewDidLoad called once?

开发者 https://www.devze.com 2023-01-18 16:29 出处:网络
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

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 calle开发者_JS百科d 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 ?


Use viewWillAppear:.

0

精彩评论

暂无评论...
验证码 换一张
取 消