2011-03-26 6 views
0

私のアプリケーションには、RootViewControllerAccountInfoViewControllerの2つのビューがあります。UITextFieldテキストを設定する

マイAccountInfoViewControllerは次のようになります。ここでは

- (void)editAcctInfo:(Account *)acct { 
    if (self.acctInfoViewController == nil) { 
     AccountInfoViewController *a = [[AccountInfoViewController alloc] 
             initWithNibName:@"AccountInfoViewController" 
             bundle:[NSBundle mainBundle]]; 
     self.acctInfoViewController = a; 
     [a release]; 
    } 

    if (acct != nil) { 
     self.acctInfoViewController.acct = acct; 
    } 

    //Hide Toolbar 
    [toolbar removeFromSuperview]; 
    [self.navigationController pushViewController:self.acctInfoViewController 
             animated:YES]; 
} 

は私AccountInfoViewControllerの私viewDidLoad方法です:

- (void)viewDidLoad 
{ 
    UIBarButtonItem *saveButton = [[UIBarButtonItem alloc] initWithTitle:@"Save" 
                    style:UIBarButtonItemStylePlain 
                    target:self 
                    action:@selector(saveAccountInfo:)]; 
    acctBalance.text = acct.balance.accessibilityValue; 
    acctName.text = acct.name.accessibilityValue; 
    //acctName.text = @"Test Text"; 

    self.title [email protected]"Edit Account"; 
    self.navigationItem.rightBarButtonItem = saveButton; 
    [super viewDidLoad]; 
} 

ときI私RootViewController

#import <UIKit/UIKit.h> 
#import "Account.h" 

@interface AccountInfoViewController : UIViewController { 

    IBOutlet UITextField *acctName; 
    IBOutlet UITextField *acctBalance; 
    Account *acct; 
} 

@property (nonatomic, retain) UITextField *acctName; 
@property (nonatomic, retain) UITextField *acctBalance; 
@property (nonatomic, retain) Account *acct; 

-(void) saveAccountInfo; 

@end 

私はこれをやっていますこれを実行し、私は私の中に何も得ない私の見解の。私が "Test Text"という行のコメントを外すと、それは私の見解では問題なく表示されるので、私はそれが正しいと分かっています。 デバッグするとき、私はacctの下の値を見ることができます。実際にコード内の単語acctにカーソルを合わせると、すべての値に対して「無効なサマリー」が表示されます。

私が間違ってやっていることや、これを達成するためのよりよい方法があるかどうかについては、私はそれが私のAccountInfoViewControllerの "acct"プロパティをどのように設定しているかに問題がなければならないことを知っています。あなたがALLOC、アカウントを初期化どこで見ることができない

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 

    Account *account = [accountTableData objectAtIndex:indexPath.row]; 

    [self editAcctInfo:account]; 

} 

答えて

0

これは、私が上記のeditAcctInfoメソッドを呼び出す方法です。表示しているコードでのみ宣言しました。それはあなたのRootViewControllerに割り当てられていますか?は

if (acct != nil) { 
    self.acctInfoViewController.acct = acct; 
} 

と呼ばれていますか?

+0

これは、メソッドcall.-(ボイド)のtableViewに渡される:*アカウント= [accountTableData objectAtIndex:indexPath.row(NSIndexPath *)indexPath {アカウント:(のUITableView *)のtableView didSelectRowAtIndexPath。 [self editAcctInfo:account]; } –