2011-04-05 53 views
3

我正在使用导航控制器。我的RootViewController推送了许多视图,但它也提供了一个模态视图。该模式视图呈现一个tableView。所以我想要做的是找出我可以推动导航控制器跨模态视图,然后使用它从该模式视图推视图与tableView?或禁止,有没有办法从模态视图实现第二个导航控制器?Modal View中的NavigationController?

真正的问题是我想用tableView使用从右到左的过渡来呈现视图,这当然不适用于模态视图。

我有这样的代码之类的提供由导航控制器用于左过渡权:

NewViewController *newViewController = [[NewViewController alloc] init]; 
[self presentModalViewController:newViewController animated:NO]; 

CGSize theSize = CGSizeMake(320, 460); 
newViewController.view.frame = CGRectMake(0 + theSize.width, 0 + 20, theSize.width, theSize.height); 
[UIView beginAnimations:@"animationID" context:NULL]; 
[UIView setAnimationDuration:0.5]; 
newViewController.view.frame = CGRectMake(0, 0 + 20, 320, 460); 
[UIView commitAnimations]; 
[newViewController release]; 

的问题是OldViewController(在一个调用NewViewController)立即消失,所以NewViewController跨越过渡一个空白屏幕,而不是覆盖OldViewController。

+0

你可以用'presentModal ... animated:false'来做'UIView动画'。有没有理由压倒现有的动画? – 2011-04-05 18:42:01

+1

我试图从导航控制器中获得从右到左的动画过渡。 – 2011-04-05 19:18:38

+0

很难说出这里要问什么。这个问题含糊不清,含糊不清,... – 2011-04-06 22:58:07

回答

10

呈现UIViewController以模态方式创建一个全新的导航堆栈。你可以这样做:

//Create the view you want to present modally 
UIViewController *modalView = [[UIViewController alloc] init]; 
//Create a new navigation stack and use it as the new RootViewController for it 
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:modalView]; 
//Present the new navigation stack modally 
[self presentModalViewController:nav animated:YES]; 
//Release 
[modalView release]; 
[nav release]; 

这可以这样做,因为UINavigationController是UIViewController的子类。当加载新视图时,您可以根据需要使用它(将顶视图上的其他视图,UIView动画(如Waqas建议等))。

我希望我的问题正确。请告诉我是否没有。

+0

谢谢。我现在拥有的是:[RootViewController1] - >呈现[ModalViewController2] - >呈现[ViewController3与模态转换]。我现在想要的是:[RootViewController1] - >呈现[ModalViewController2] - >呈现[推送ViewController3与导航控制器转换]。这是否可以使用你所说明的方法? – 2011-04-05 19:23:55

+0

它应该做的伎俩。想想看,我相信这里有一个简单的解决方案 - 您可以模态地呈现第一个视图,然后在viewDidAppear方法中将其上的表视图推上去。 – nadavhart 2011-04-05 19:28:36

+0

另外,如果因为中间视图而出现延迟,您可以试着用Animated:NO模式推动它。 – nadavhart 2011-04-05 19:31:20

相关问题