I want to show animation from bottom to top when i am pushing viewController to navigationController?Do any have idea to do it?
当我把viewController推到navigationController时,我想从下到上显示动画?有什么办法吗?
RegisterViewController *registerView = (RegisterViewController *)[self.storyboard instantiateViewControllerWithIdentifier:@"RegisterViewController"];
Present
现在
[self presentViewController:registerView animated:YES completion:nil];
Dismiss
驳回
[self dismissViewControllerAnimated:YES completion:nil];
Is there any way to achieve this in navigationController?
在navigationController中有什么方法实现这个目标吗?
2 个解决方案
#1
4
Don't link Storyboard
不连接板
Present ViewController with this code
用这段代码呈现ViewController
It Will Present from bottom to top
它将从下到上呈现
UIViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"MYUnicornViewController"]; // Change the view controller name
[self.navigationController presentViewController:vc animated:YES completion:nil];
Dismiss ViewController with this code
用这个代码解散ViewController。
It Will dismiss from top to bottom
它会从上到下消失
[self dismissViewControllerAnimated:YES completion:nil];
#2
1
You can present the view controller like as answered by @PinkeshGjr, I am adding code to add navigation bar without the custom view suggested by @Pinkeshgjr.
您可以像@PinkeshGjr回答的那样显示视图控制器,我正在添加代码以添加导航条,而没有@PinkeshGjr建议的自定义视图。
Instead you can simply add your view controller in Navigation controller and present.
相反,您可以在导航控制器中添加视图控制器并呈现。
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
#1
4
Don't link Storyboard
不连接板
Present ViewController with this code
用这段代码呈现ViewController
It Will Present from bottom to top
它将从下到上呈现
UIViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"MYUnicornViewController"]; // Change the view controller name
[self.navigationController presentViewController:vc animated:YES completion:nil];
Dismiss ViewController with this code
用这个代码解散ViewController。
It Will dismiss from top to bottom
它会从上到下消失
[self dismissViewControllerAnimated:YES completion:nil];
#2
1
You can present the view controller like as answered by @PinkeshGjr, I am adding code to add navigation bar without the custom view suggested by @Pinkeshgjr.
您可以像@PinkeshGjr回答的那样显示视图控制器,我正在添加代码以添加导航条,而没有@PinkeshGjr建议的自定义视图。
Instead you can simply add your view controller in Navigation controller and present.
相反,您可以在导航控制器中添加视图控制器并呈现。
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