Vyachaslav Gerchicov
Vyachaslav Gerchicov

Reputation: 2457

Change a list of presented view controllers in swift like

My app has complex transition sequence:

  1. A presents modal B
  2. B presents modal C
  3. A presents D (behind B)
  4. C is dismissed to D

The problem is how to insert D. In case of push-pop animations navigationController has viewControllers property which I can change as I wish. But what to do in case of modal view controllers?

Upvotes: 0

Views: 404

Answers (2)

Vyachaslav Gerchicov
Vyachaslav Gerchicov

Reputation: 2457

My solution is:

  1. A presents modal NC (UINavigationController with hidden navigation bar) with B as rootViewController
  2. NC presents modal C
  3. NC rootViewController is replaced with D
  4. C is dismissed to NC

In other words I didn't find how to replace presenting/presented view controllers but I can build in them into navigation controllers. It is better than built in views and adding child view controllers because you can still use present/dismiss without of additional difficulties.

It seems UITabBarController may work too for this purpose.

Upvotes: 0

Aura
Aura

Reputation: 246

You could put D controller's view inside a view on controller A - and you manage it like a normal view - hide / show with animation.

You could have something like this in controller A:

let dController = DController()
if let dView = dController.view {
   self.view.addSubview(dView)
}
 

Upvotes: 0

Related Questions