I've been having trouble getting data to pass from a detail view controller to the master one. The hierarchy of the interested parts is
TabBarController -> Profile View Controller --segue--> Navigation Controller -> Detail View Controller
The Detail View Controller contains a UICollectionView of images, each image having a tap gesture recognizer. What I'm trying to do is to tap on one of the images, pass the indexPath.row to the ProfileViewController and GO BACK programmatically.
When I go to the Detail View Controller there is a Back button already there so the idea is: if user presses on "Go Back" button, nothing happens. If user presses on image, the back button is triggered by itself and the image in the Profile changes.
So far I can tap on the images, pass the indexPath.row but I can't manage to go back to the previous View Controller.
I've tried navigationController?.popViewControllerAnimated(true)
and navigationController?.popToRootViewControllerAnimated(true)
but both of them don't work (I put them into the tap function for the gesture and nothing happens with regards to the navigationController, the tap function works fine)
When I print the following I get 1 navigationController.viewControllers.count
The only thing that I managed to get working is dismissViewControllerAnimated
however that goes out of the TabBarController to another view that is before that.