Xcode - Show segue from modal view controller - swift

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.

Related

Navigation Controller with Show relationship

I would like to SHOW the view when I click on a specific icon in the Tab bar. Currently the view is PRESENTED, not PUSHED. I can't access to properties via the main storyboard, I really don't know how to do it.
For presenting a controller, the segue type should be : Present Modally
For pushing the controller in navigation stack, the segue type is : Show

How to add the default back button in the navigation view controller from storyboard or in swift?

Okay so I have one main view controller and then I added a navigation view controller from the 'Editor -> Embed In -> Navigation Controller' toolbar and then I segued from the first view controller button to the empty navigation controller scene because if I segued directly to the signup or signin VC the main view controller would end up having a bar on the top like the navigation view controller. But now i added an bar button item "Back" and segued to the main VC and the bar comes back with a builtin back button. So how can i add a default back button or any back button without having the main VC becoming a navigation view controller. Here is a link to an image: https://www.dropbox.com/s/1623a45v846ijn8/Screen%20Shot%202015-09-27%20at%2012.23.26%20PM.png?dl=0
The problem is that you have two navigation controllers when you should only have one.
You should make your initial view controller a UINavigationController, and set your previous initial view controller as the root. If you don't want to see the bar, just set the bar to be hidden on your viewWillAppear, and unhide it on the Sign In / Sign Up pages.

Calling popToRootViewControllerAnimated from a modal

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.

How can i dismiss modalViewController without leaving current view?

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.

UINavigationView in modal view

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.