3

我想从底部到顶部显示动画时,我将viewController推送到navigationController?有没有想法做到这一点?如何在navigationcontroller中从下到上显示/关闭viewcontroller?

RegisterViewController *registerView = (RegisterViewController *)[self.storyboard instantiateViewControllerWithIdentifier:@"RegisterViewController"]; 

目前

[self presentViewController:registerView animated:YES completion:nil]; 

辞退

[self dismissViewControllerAnimated:YES completion:nil]; 

有没有办法在navigationController来实现这一目标?

回答

4

不要使用此代码

它将从底部出示链接故事板

当前视图控制器顶部

UIViewController *vc; 
    vc = [self.storyboard instantiateViewControllerWithIdentifier:@"VC1"]; 
    [self.navigationController presentViewController:vc animated:YES completion:nil]; 

辞退的ViewController使用此代码

它将从顶部解雇上下

[self dismissViewControllerAnimated:YES completion:nil]; 

enter image description here

+0

哦!我很惊讶,但在这种情况下,它隐藏导航栏。 –

+0

为什么你不创建自定义设计,看起来像在该视图控制器上的导航 – PinkeshGjr

+0

它隐藏导航栏,因为这种解决方案,你是模态呈现,而不是推到导航堆栈上。 – william205

1

你可以提出类似的@PinkeshGjr作为回答视图控制器, 我加入的代码添加导航栏不由@Pinkeshgjr建议的自定义视图。

相反,您可以简单地将您的视图控制器添加到导航控制器中并呈现。

UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];//Change your storyboard name 
UIViewController* myCopntroller = [storyBoard instantiateViewControllerWithIdentifier:@"myViewController"];//Your view controller 
UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:myCopntroller];//Added in navigation controller 
[self presentViewController:nav animated:YES completion:nil];//Present you viewcontroller 
相关问题