1

I have 4 View Controllers (A, B ,C ,D). I can go from A -> B , B -> C. In the View Controller C what I want to do, Remove the B and C then show view controller D. so that If I go back from D it goes to A.

I want to perform this with a transition smoothly. D already has a UIViewControllerTransitioningDelegate methods implemented. So in C I should be able to remove itself and B then show D with the D's Transition like nothing happened. I am not using a NavigationController. What are the approaches I can use to do this ?

Im using Xcode 9 and Swift 4 Thanks

Bhanuka Yd
  • 646
  • 8
  • 25

2 Answers2

0

Assuming all the viewControllers are under the same UINavigationController, why don't you try to use the setViewControllers:animated: method of the navigationController and set the array to be [viewControllerA],

or popToViewController:animated: and pass in the viewController A,

or assuming the VC A is the root VC, use popToRootViewControllerAnimated: to pop to the root.

Hope this helps

congsun
  • 144
  • 5
  • unfortunately I am not using a navigation controller. Is it possible to use a navigation controller without showing navigation bar ontop of the view? – Bhanuka Yd Jan 29 '18 at 15:55
  • Yes, use the `isNavigationBarHidden` property or `setNavigationBarHidden(_:animated:)` method in the UINavigationController – congsun Jan 29 '18 at 15:59
0

since I couldn't find a way to remove the VC s below D. I went to another approach. When Ds Segue finished (finished transition from C) I cleaned the B and Cs resources. this freed up memory. so That is the workaround I found.

And when I unwind from D to A all the VCs above A is removed automatically

Bhanuka Yd
  • 646
  • 8
  • 25