开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜