2012-02-08 77 views
3

我目前正在为我的公司开发iPhone应用程序,我遇到了一个奇怪的事情。presentModalViewController - ViewController自动消失后呈现

我查看数字体系是这样的:

包含5个选项卡包含一个UINavigationController每个标签的UITabBarController。 到目前为止,一切都很完美。

现在我想使用的代码此线对 的UITabBarController经由presentModalViewController方法呈现模态的视图控制器:

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

的FilterOptionsView是含有只不过是一个黑色背景在 时刻正常的UIViewController 。

会发生什么情况是视图呈现,几秒钟后神秘消失。 这是怎么回事?在没有点我打电话dismissModalViewController方法。

我在展示mailcomposer时已经遇到了这个问题。

问候, 弗洛里安

+0

尝试更改self.tabBarController for [self.view presentModalViewController:filterView animated:TRUE]; – oriolpons 2012-02-08 15:07:49

+0

发生同样的错误。我无法从视图中呈现模式视图控制器,所以我尝试[self presentModalViewController:filterView animated:TRUE]; – user1197467 2012-02-08 15:12:38

+0

你使用ARC吗?尝试使您的filterView作为类变量 – Chakalaka 2012-02-08 15:22:11

回答

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]; 

附:我建议不命名视图控制器“filterView”它会更好地命名为“filterViewController”

+0

可悲的是不适合我:< – user1197467 2012-02-08 15:37:31

+0

感谢您的答案,但我找到了解决方案。 [self.navigationController.tabBarController presentModalViewController:filterView animated:TRUE]; 这样做的技巧... – user1197467 2012-02-08 15:39:01

+0

在你的结构中的callFilterOptions方法?在视图控制器? – ader 2012-02-08 15:40:11

相关问题