I want to show animation from bottom to top when i am pushing viewController to navigationController?Do any have idea to do it?
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?
Don't link Storyboard
Present ViewController with this code
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
It Will dismiss from top to bottom
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
Objective C:
Present from Bottom to Top
RegisterViewController *registerView = (RegisterViewController *)[self.storyboard instantiateViewControllerWithIdentifier:@"RegisterViewController"];
[self.navigationController presentViewController:registerView animated:YES completion:nil];
Dismiss from Top to Bottom
[self dismissViewControllerAnimated:YES completion:nil];
Swift:
Present from Bottom to Top
let registerView = self.storyboard?.instantiateViewController(withIdentifier: "RegisterViewController") as! RegisterViewController
self.navigationController?.present(registerView, animated: true, completion: nil)
Dismiss from Top to Bottom
self.navigationController?.dismiss(animated: true, completion: nil)
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.
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.