How to transit from the last view in a tab to the last view of another tab

"My project is made of 2 tabs.


There are a couple of views in the first tab and in the last view (named "writeTask) there is a button that by tapping it I would like to nagivate the user to the last view of the second tab. ("newTask)


There are 2 view in the second tab a table view(named "myTasks") and a regular view("newTask"). "myTasks" displays all tasks a user wrote and "newTask" display a single task.


The logic flow I want to achieve:


1: The user enter all the requested information of a task through all the views in the first tab and finally reach to the last view named "writeTask". Here the user is supposed to tap "confirm" button.


2: Upton tapping "confirm" I want to navigate the user to the second view(named "newTask") of the second tab which shows the very task the user just entered. The user can go to "myTasks" table view by tapping button on the top left corner.


My first approach:


Upon tapping the button, I

instantiateViewController
"myTasks" and do
self.present(myTasks, animated: true, completion: nil)
. But now the user will go to "myTasks" table view first without going straight to "newTask". I tried to solved this by perform a segue in its
viewDidload
by
self.performSegue(withIdentifier: "showTaskDetails", sender: self)


Issue: the segue is performed too late (after the view is load and the user will see the "myTasks" view for half second).

Second approach:


I create a modal segue between the tap button and the "newTask" view. And I create an unwind segue between "newTask" view and "myTasks" table view. So the user will be navigated to "newTask" view, they can go back to "myTasks" through the unwind segue.


Issue: during the unwind segue the "wirteTasks" view will be displayed for a short moment before "myTasks" table view is displayed.

Replies

Hi,


tabBarController.selectedIndex = 0

will show the first viewController.


Try settings it to 1. 🙂


Dirk