Present modal VC under tabbar, from tabbar controller - ios

I have to present a modal VC under a tabbar. I Have to present it from a tabbar controller
player.modalPresentationStyle = UIModalPresentationOverCurrentContext;
[self presentViewController:player animated:YES completion:^{
[self.view bringSubviewToFront:self.tabBar];
}];
That's my code. In this case my model VC covers the tabbar. Is there a way to fix this?

Related

Dismissing a ViewController shown as Popover segue from within another Popover

My storyboard is using a UINavigationController(VC0), I segue using a UIPopover to load a new UIViewController (VC1). From this new UIViewController, I am popping to a new UIViewController (VC2). When I attempt to close this newest popover, I am being quit back to the UINavigationController.
The code that I'm using in VC0 to show the VC1 as popover, VC1 to VC2 is the same code (different identifier though):
[self performSegueWithIdentifier:#"titlePopover" sender:self];
The code that I'm using in VC2 to dismiss the popover is:
UIViewController *vc = [self presentingViewController];
[self dismissViewControllerAnimated:YES completion:^{
[[vc presentingViewController] dismissViewControllerAnimated:YES completion:nil];
}];
What it does is dismisses VC2, shows VC1 for a split second, then dismisses VC1 and goes back to the VC0. I want to be able to dismiss VC2 only, so that I'm on VC1
If you performing sugue modally, use code navigate back:
[self dismissViewControllerAnimated:YES completion:nil];
If performing push segue, use code to navigate back:
[self.navigationController popViewControllerAnimated:YES];

How can i present/dismiss viewcontroller from bottom to top in navigationcontroller?

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

Present a blurred UIViewController on top of another UIViewController

I have 2 VCs - firstVC and secondVC.
secondVC's view's color is clear color and it has a UIVisualEffect view with dark blur.
I want to present secondVC modally on firstVC but when I do that, firstVC becomes black.
Thank you
You need to set the modalPresentationStyle appropriately on the presented (secondVC) controller.
UIModalPresentationOverFullScreen or UIModalPresentationOverCurrentContext will provide the effect of the second VC's content over the top of the first VC.
if ios version >= 8.0 then
SecondViewController.modalPresentationStyle = UIModalPresentationOverCurrentContext;
[self presentViewController:SecondViewController animated:YES completion:nil];
if using ios7 & navigation controller then
self.navigationController.modalPresentationStyle = UIModalPresentationCurrentContext;
[self presentViewController:SecondViewController animated:YES completion:nil];
if there is no navigation controller then
self.modalPresentationStyle = UIModalPresentationCurrentContext;
[self presentViewController:SecondViewController animated:YES completion:nil];

how could i push view controller to navigation controller

I want to go from my Login Page to the MainMenuViewController but the MainMenuViewController is a navigation Controller.
I searched for a while but it still doesn't work correctly. Could anyone tell me what's going on?
My code:
MainMenuViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier: #"MainMenuViewController"];
[self presentViewController:vc animated:YES completion:nil];
What exactly is the issue? This will present a view controller that you choose, if you want to get the navigation view to show up correctly you will want to transition not to the MainMenuViewController, but the root view controller for that. When you look at the storyboard, you can see the navigation controller that segues to the MainMenuViewController, present that view controller instead of the MainMenuViewController.
Set the storyboard ID for your navigation controller and write the below code in the function.
UINavigationController * navigationController = [[UIStoryboard storyboardWithName:#"Main" bundle:nil] instantiateViewControllerWithIdentifier:#"SecondNavigationController"];
[self presentViewController:navigationController animated:YES completion:nil];
Hope this helps. :)

Switching underlaying view controllers iOS 8

This is the goal :
I have a navigation controller (NC1), that is presenting modally some view controller (VC). When I do some action in that view controller, I need to (invisibly for the user) dismiss VC, dismiss NC1, then present another navigation controller (NC2) and present the same view controller VC.
In iOS 7.0, 7.1 this is working well via this (slightly adjusted) code:
[controller dismissViewControllerAnimated:NO completion:nil]; //dismiss VC
[self.presentedViewController dismissViewControllerAnimated:NO completion:nil]; //dismiss NC1
SomeViewController * someViewController = [[SomeViewController alloc] init]; // root vc for NC2
NavigationController * navigationController = [[NavigationController alloc] initWithRootViewController:someViewController]; //NC2
SomeViewController2 * someViewController2 = [[SomeViewController2 alloc] init];
[navigationController presentSomehow:someViewController2 animated:NO completion:nil]; //another pushed to NC2
[someViewController2 presentViewController:controller animated:NO completion:nil]; //present VC again
but in iOS 8 (Xcode 6.0) it seems that even after dismissing, VC remains active and the app crashes at the last line with:
Application tried to present modally an active controller ...
And of course if I move the code to completion blocks the changes are visible to user (and ugly).
Is there a way to check or force the VC to leave the active state, or some other way to simulate the iOS 7 behavior?
Thanks for answers!

Resources