I would like to place a UINavigation View within a Modal view but I am having loads of problems. I managed to get the modal view working, but when trying to put a UINavigationController in it it just comes up with a blank screen.
Does anybody know how to do that properly?
Create a UINavigationController, initialize it with your UIViewController at its root, and then present the navigation controller modally.
Related
I am presenting a modal view controller with a tableView, and then want to perform a push segue when a cell is tapped inside the modally presented view controller.
I set up a view controller and a show (push) segue from the modal view controller to the new view controller, but when I call performSegueWithIdentifier, the new view is presented in a modal fashion (slides up) on top of the initial modal view, instead of coming in from the right.
Anyone know what's going on?
Thanks!
For anyone who has this issue in the future, I figured it out:
You need another navigation controller. So I perform a modal segue to a new navigation controller, and set the modal view controller as the root view controller of the navigation controller. I can then perform a show segue from the modal view controller to any other as normal.
:)
As of Xcode 11.4 (possible earlier) you can also just select the destination view controller and in the right inspector pane under the attribute inspector you have the option: "Transition style" and "Presentation" which will allow you to change from Automatic to Full Screen for example. That way you can overwrite that when you use "push" from a modally presented view controller, the segue will always present the next view controller modally.
Basically once I dismissed the modal view, my customized UIToolbar no longer clickable.
Here is my design:
a customized UIToolbar at the bottom of the screen
top part of the screen is associated with a container view controller
[note] I added the top two items above into a root view controller and assigned to UIWinow's root view controller. The container view can be changed whenever toolbar items are clicked.
then, each toolbar item associated with a UINavigationController so that it's navigable.
within a UIViewController of a navigation, I present a view modally. The modal view does NOT cover the full screen as a result of the entire design...
after i dismiss the modal view, the UIToolbar items are no longer clickable.
I think the 'bug' is resided in where i presented the modal view, so I also tried to present modal view using root view controller, then there is also other issues...
maybe someone has more insight on this, that will be really appreciated :)
Thanks.
Try releasing the modalViewController as soon as its no longer needed. If you are using ARC, set it to nil. Allocate a new one when a modalView is needed.
I have a modal that I am calling presentModalViewController to display from a custom menubar. This menubar is overlaying a viewcontroller that is pushed from a tableView cell.
Now... that all being said, I need to find some way to jump the user back to the root of the tableView from the modal screen. Is this possible? I've been fighting with this for the past couple of hours with no results.
If you're starting from a tablview, drilling down to a detail view via a navigation controller, and then presenting a modal view controller on top of that detail view, you'd have two steps to get back to your list/tableview: First you'd dismiss your modal view controller, then you'd pop your detail view off your navigation stack.
That should put you back where you started (at the tablview), if I'm reading this correctly.
You could pass a reference to the navigation controller to the modal view, and then immediately after calling dismissModalViewControllerAnimated, you can use the reference to the navigationController to pop back to the root view controller.
My application is view based app. First view is login view. After login view i have MainMenuCcontroller which has a tabBarController:
#interface RunnoMainMenuController : UIViewController {
IBOutlet UITabBarController *tabBarController;
}
From login view controller, i am going to MainMenuController using this line of code:
[self presentModalViewController:mainMenu animated:YES];
this controller has 4 tabs. Now i need to do some stuff in viewWillAppear of a tabBarItem. viewWillAppear is not called when i tap a tabBarItem. I have a button in one of those tabBarItem's view which pops up a table view controller using presentModalViewController. This tableView uses dismissModalViewControllerAnimated:YES to disappear it. When i pop up this tableview and dismiss it then viewWillAppear of every tabBarItem works fine. If i will dismiss modalViewController in MainMenuController then it will again go back to login view. How can i dismiss modalViewController without leaving current view or any other solution? Thanks in advance.
You may need to consider how your views are presented. The tab bar controller should always be the window's root view controller. From the Apple docs:
When deploying a tab bar interface, you must install this view as the
root of your window. Unlike other view controllers, a tab bar
interface should never be installed as a child of another view
controller.
Rather than present your login view as the root view and the tab bar as a modal view controller, try it the other way round. The tab bar controller as root, with the login view as presented as a modal view controller from the view controller of whichever tab is shown initially. Dismissing this will then reveal the tab bar controller.
I've created my own ProfileUIViewController class that is a UINavigationControllerDelegate. I display this view in two ways:
From an IBAction within A-UIViewController.m, as a UIModalViewController. A-UIViewController has a UINavigationBar when it's loaded, but when I display the modal, it no longer has the navigation bar.
From clicking a table cell row within B-UIViewController.m, by pushing it onto the stack. B-UIViewController has a UINavigationBar when it's loaded, and the ProfileViewController keeps the navBar as desired :)
What I am looking to do is keep the UINavigationBar when the view is loaded as a modal in case 1, filling in INSIDE the UINavigationBar instead of laying over the entire view. (IE, I would like the modal to appear within A-UIViewConroller underneath the navBar - making it a smaller size)
Can someone help me with this? Do I need to make my own custom ModalViewController class - wouldn't this be ProfileUIViewController? Does it need some instance methods that I'm not giving it? Any direction would be great:)
The navigation bar is managed by the navigation controller, not by your view controller. When you push your view controller into the navigation controller, the navigation controller uses the information in the navigationItem to determine what to put in the navigation bar. But when you display your view controller modally, it's not inside any navigation controller so there is no bar.
One simple solution for the modal case is to create a new UINavigationController with your view controller as its root view controller, and display that modally instead of displaying your view controller directly.