Reputation: 105
going to try and explain my problem as simply as I can. Tried a lot of searching and can't find a solution.
I'm trying to segue to a view controller that sits within a different tab in a tab bar controller and a navigation controller like this...
I've got a collection view on the HomeVC and when a user taps an item I want it to take them to the ViewRecipeVC via the navigation controller to view the recipe.
I want the navigation bar to appear on the ViewRecipeVC with a back button (tbh I don't mind if the back button takes them back to HomeVC or the RecipesTableVC/TableView if that presents a simpler solution).
I need the navigation controller to be in place as any images or links tapped in the ViewRecipeVC open in a new view and the user can then tap back to navigate back.
I can achieve something by segueing directly to the ViewRecipeVC from the HomeVC but the view presents as a sheet and then another sheet on top of that when an image or link is tapped and isn't a nice user experience.
Is this even possible? Apologies if I've not described what I'm trying to do here, still very noob and completely self taught, any help appreciated!
Upvotes: -1
Views: 59
Reputation: 77681
Couple notes:
Programmatically switching to a different Tab can be very confusing to the user... but, assuming you feel your program flow/needs will benefit from that...
You cannot do this with "standard" Storyboard Segues - you'll have to write some code.
One option would be to create a UIStoryboardSegue
subclass to use as a Custom Segue. However, that may be more work than writing the code in an @IBAction
func.
Another option, which may be a better approach...
Embed your "Home" view controller in a navigation controller, and add a show/push segue to the "Recipe Details" controller.
Your "Recipe List" table view controller will still have its own "push to details" segue.
Now, when the user taps the button on the HomeVC to "jump to Recipe Details" the DetailsVC will be pushed onto that navigation controller. The Back button will take them back to HomeVC.
When the user selects a recipe from the table view, the DetailsVC will be pushed onto that navigation controller. The Back button will take them back to RecipeListVC.
Here's how that would look in Storyboard:
Upvotes: 1