从底部加载导航ViewController

时间:2012-08-09 08:44:08

标签: iphone ios cocoa-touch uiviewcontroller uinavigationcontroller

我有四个ViewControllers,其中使用UINavigationController加载ViewControllers。我可以逐个切换到每个ViewController。

问题是,因为我使用的是NavigationController,所有的ViewControllers都是从Left或Right加载的。但我想从底部加载ViewController。我知道我可以使用presentModalViewController从底部呈现ViewController。但它不等同于导航控制器,因为从第4个ViewController,如果我按下一个按钮,我需要来到第一个ViewController。

如何从NavigationController底部呈现ViewController?

3 个答案:

答案 0 :(得分:10)

试试这个:

CATransition *animation = [CATransition animation]; 
[animation setDuration:2]; 
[animation setType:kCATransitionPush]; 
[animation setSubtype:kCATransitionFromTop]; 
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]]; 
SecondView *sObj=[[SecondView alloc] initWithNibName:@"SecondView" bundle:nil];
[self.navigationController pushViewController:sObj animated:YES];
[[sObj.view layer] addAnimation:animation forKey:@"SwitchToView1"]; 

答案 1 :(得分:0)

使用此功能可能会对您有所帮助

[UIView beginAnimations:@"Hide Me" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:kAnimationDur];
subScroll.frame = CGRectMake(0,ksubScrollHideY,ksubScrollW,ksubScrollH);
clickPic.frame = CGRectMake(kButtonX,kButtonHiddenY,kButtonW,kButtonH);
[UIView setAnimationDelegate:self];
[UIView commitAnimations];

快乐编码:)

答案 2 :(得分:-2)

创建viewController后,而不是:

[self.navigationController pushViewController:blablabla animated:YES];

做的:

[self presentModalViewController:blablabla animated:YES];

它将来自底部。

回去,只说:

[self dismissViewControllerAnimated:YES];