2011-07-26 11 views
0

私はpresentmodalviewを使って子ビューをロードする親ビューコントローラを持っています。正確に言うと、この子ビューはログインページです。iPhone App Dev - 子から親への戻り値

ログインページには2つのテキストフィールド(電子メールとパスワード)と「ログイン」ボタンがあります。ログインボタンが押されたときにデータ入力が有効であれば、ユーザーの詳細をルートビューコントローラに送信して、ユーザーが存在する場合はユーザーオブジェクトを作成し、無効な詳細をユーザーに示すuialertviewを表示します入力されました。

私の子ビューでは、私は「ログインボタン」にリンクされ、次の機能があります。

-(IBAction) signIn:(NSString*)userEmail with:(NSString*)userPassword{ 
    //takes text field values and instantiates a dbConnector object to 
    //check to see if user exists - must also post uialertview if user details incorrect 
    NSString* uName = [email text]; 
    NSString* pword = [password text]; 
    userDetails = [[NSMutableArray alloc] initWithObjects:uName, pword, nil]; 
    NSLog(@"%@", userDetails); 
} 

をボタンが押された後に戻ってrootviewcontrollerにuserDetailsの配列を渡すための最良の方法は何ですか?

SOLUTION - プロトコル&代表

答えて

0

あなたはプッシュする前に、ユーザーオブジェクトを渡すか、別のビューコントローラを提示する必要があります。

this answerを参照してください。この助けを願っています。

1

ParentViewControllerにUserDeatails配列を作成し、ChildViewControllerでボタンが押されたときにその値を設定します。

ただし、ParentViewControllerのオブジェクトを作成する必要があります。

ParentViewController * parentView = [[ParentViewController alloc] initWithNibName:@ "ParentViewControllerName"バンドル:nil];

parentView.userDeatails = userDetails_in_ChildView;

0

だけ

文字列* strUsernameのようなデリゲートファイルに変数を宣言します。 文字列* strPassword;また

とプロパティを作成し、そのために合成..

続いた後、あなたはこのようにしたい今までに、デリゲートのオブジェクトを作成します。..

NavigationBarAppDelegate * appDelegate =(NavigationBarAppDelegate *)[[のUIApplication sharedApplication ]デリゲート];

appDelegate.strUsername = uName; appDelegate.strPassword = pword;

今、この値は、すべてが、それは上記のように、デリゲートオブジェクトを作成し得るwar..just取得することです...

NavigationBarは自分のアプリケーションの名前です。

関連する問題