2012-02-08 4 views
3

私の会社のiPhoneアプリケーションを開発中です。私は奇妙なことに遭遇しました。 UINAvigationControllerを含むすべてのタブと5つのタブを含むpresentModalViewController - プレビュー後にViewControllerが自動的に消えます

UITabBarController:

マイビューHierachyは、このようになります。 これまでのところすべてが完璧に機能します。

今、私はこのコードの行を使用して UITabBarControllerにpresentModalViewControllerメソッドを介してモーダルビューコントローラを提示したい:

-(void)callFilterOptions 
{ 
    FilterOptionsView *filterView = [[FilterOptionsView alloc] init]; 
    [filterView setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal]; 
    [self.tabBarController presentModalViewController:filterView animated:TRUE]; 
} 

FilterOptionsViewは 現時点では黒の背景しか含まない通常のUIViewControllerであります。

何が起こるかは、ビューが表示され、数秒後に謎めいて消えることです。 なぜこれが起こっていますか?いいえ、私はdismissModalViewControllerメソッドを呼び出しています。

メールコンポーザーを提示するとき、すでにこの問題に遭遇しました。

挨拶、 フロリアン

+0

[self.view presentModalViewController:filterView animated:TRUE]のself.tabBarControllerを変更してみてください。 – oriolpons

+0

同じエラーが発生します。そして私は[self presentModalViewController:filterView animated:TRUE]を試したので、ビューからモーダルビューコントローラを表示できません。 – user1197467

+0

あなたはARCを使用していますか?クラス変数としてfilterViewを作成しようとしてください – Chakalaka

答えて

0
UINavigationController *myNavController = [self navigationController]; 
[myNavController presentModalViewController:filterView animated:TRUE]; 

またはより良いアプローチは次のようになります。

UIApplication *myApp = [UIApplication sharedApplication]; 
noIBAppDelegate*appDelegate = (noIBAppDelegate*)myApp.delegate; 
[appDelegate.tabBarController presentModalViewController:filterView animated:YES]; 

却下する:

UIApplication *myApp = [UIApplication sharedApplication]; 
noIBAppDelegate*appDelegate = (noIBAppDelegate*)myApp.delegate; 
[appDelegate.tabBarController dismissModalViewControllerAnimated:YES]; 

P.S.ビューコントローラ "filterView"の名前を付けないことをお勧めします。 "filterViewController"という名前の方がいいでしょう。

+0

悲しいことに私のためには動作しません。< – user1197467

+0

これまでのお返事ありがとうございました。 [self.navigationController.tabBarController presentModalViewController:filterView animated:TRUE]; それはトリックでした... – user1197467

+0

あなたの構造ではどこにcallFilterOptionsメソッドですか?ビューコントローラで? – ader

関連する問題