从底部加载导航视图控制器(Load a Navigation ViewController from

2019-07-30 20:41发布

我有四个ViewControllers,其中ViewControllers使用加载UINavigationController 。 我能够通过一个切换到每一个的ViewController。

问题是,因为我使用所有的ViewControllers要么被从左侧或从右侧装入NavigationController。 但我想从底部加载视图控制器。 我知道我可以使用presentModalViewController从底部呈现的ViewController。 但它并不等同于导航控制器,因为,从第4 ViewController中,如果我按一个按钮,我需要来第一次的ViewController。

我可以如何呈现一个视图控制器从NavigationController底部?

Answer 1:

试试这个:

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


Answer 2:

使用此可能,这将帮助你

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

编码愉快:)



Answer 3:

在创建后的viewController,而不是:

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

做:

[self presentModalViewController:blablabla animated:YES];

它会从底部。

回去,只说:

[self dismissViewControllerAnimated:YES];


文章来源: Load a Navigation ViewController from bottom