I'm creating an IOS Application in swift and I found a pretty big problem in my case.
If I would do this in Android I would use fragments and just replace the current fragment to a new one, but nothing seem to be equal to fragment in swift, so.
I start on view controller A and then I'm navigating to view controller B (The user should just pick their name in this view) and from B I want to navigate to C. But when I navigate to C I need view controller B to be dismissed to avoid the stacking. But I can't find a good way to just remove the current view controller and navigate to a new one.
func navigateToService(selectedCar: String!){
if let storyboard = storyboard{
let vc = storyboard.instantiateViewController(withIdentifier: "BookServiceViewController") as! BookServiceViewController
self.dismiss(animated: true) //<---
vc.selectedCar = selectedCar
self.present(vc, animated: true)
}
}
I've tried this and a lot more so far. But nothing seem to work in my case. The code I've added in the thread is just closing the view immediately and is not opening a new one.
So how can I navigate from A -> B -> Dimiss B -> C?
TEMPORARY EDIT, WILL BE REMOVED
func navigateToService(selectedCar: String!){
self.dismiss(animated: true) {
if let storyboard = self.storyboard{
let vc = storyboard.instantiateViewController(withIdentifier: "BookServiceViewController") as! BookServiceViewController
vc.selectedCar = selectedCar
self.present(vc, animated: true)
}
}
}