2012-03-02 14 views
0

私はpresentModalViewController経由でそこにビューを持つアプリを作った。ios5 presentmodalviewcontroller複数のビュー

最初のビューは、2番目のビューは、3番目のビューは私の質問は、ということですthirdview.m

- (IBAction)backtomain:(id)sender {  
    [self dismissModalViewControllerAnimated:YES];} 

ある

#import "thirdview.h" 
- (IBAction)dismiss:(id)sender {  
    [self dismissModalViewControllerAnimated:YES];} 
-(IBAction)gohead:(id)sender{  
    thirdview *third = [[thirdview alloc] initWithNibName:nil bundle:nil];  
    [self presentModalViewController:third animated:YES];} 

secondview.mあるViewController.m

#import "secondview.h" 
- (IBAction)pushme:(id)sender {  
    secondview *second = [[secondview alloc] initWithNibName:nil bundle:nil];  
    [self presentModalViewController:second animated:YES];} 

です私が3番目のビューでボタン(backtomain)をクリックすると、2番目のビューではなく最初のビューに戻りたい。だから私はbacktomain機能を整理することができますか?

ありがとう〜

答えて

0

次の手順を実行してください。

  1. 2番目のビューコントローラの参照を格納します。

    @property(nonatomic、strong)secondview * modalV; - (IBAction)pushme:(id)送信者 { secondview * second = [[secondview alloc] initWithNibName:なしバンドル:なし]; self.modalV = second; [second release]; [self presentModalViewController:modalV animated:YES];

    }

2.Setまでの第2のビューコントローラに続い

を使用すると、「backToMain」を押してメッセージを送信する第三のビューコントローラ内のプロトコル、メッセージ

- (void) backToMain 
{ 
    if(self.modalV) 
    { 
     [modalV dismissModal]; // define this in third 
     [modalV release]; 
    } 

    [self dismissModalViewControllerAnimated:YES]; // it will dismiss second 
} 

ハンドル3番目に

- (void) dismissModal 
{ 
    [self dismissModalViewControllerAnimated:YES] 
} 
+0

こんにちは、私は初心者ですので、私はあなたのコードをよく理解できません、ここに私ですファイル:http://www.tempfiles.net/download/201203/232758/delay-actions.html、それを確認できますか? –

関連する問題