0

This is the diagram of my project:

enter image description here

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.

Frostless
  • 818
  • 1
  • 11
  • 33

1 Answers1

0

This is the new approach I have come up with:

let mainStoryboard = UIStoryboard(name: "Main", bundle: Bundle.main)
    let vc: UITabBarController = mainStoryboard.instantiateViewController(withIdentifier: "tabBarController") as! UITabBarController


    let nvc = vc.viewControllers?[1] as! UINavigationController
    let destinationVC = nvc.viewControllers[0] as! myTasksTableViewController

    destinationVC.task = task

    vc.selectedIndex = 1

    self.present(vc, animated: true, completion: nil)
Frostless
  • 818
  • 1
  • 11
  • 33