2011-03-26 7 views
0

내 응용 프로그램에서 두 개의 뷰를 RootViewControllerAccountInfoViewController으로 처리했습니다.UITextField 텍스트 설정

AccountInfoViewController은 다음과 같습니다에서

#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 

RootViewController 나는이 일을 오전 :

여기
- (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]; 
} 

AccountInfoViewControllerviewDidLoad 방법 :

- (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 이걸 실행하면, 나는 아무것도 얻지 못한다.내보기의. "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

그것이 방법 전화예요 (보이드)에 전달되고있는 tableView (jQuery과 *)를 tableView didSelectRowAtIndexPath (NSIndexPath *) indexPath { 계좌 계좌 * = [accountTableData objectAtIndex : indexPath.row]; [self editAcctInfo : account]; } –