0

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?

Vyachaslav Gerchicov
  • 2,317
  • 3
  • 23
  • 49
  • @CouchDeveloper 1)I already have a code which already has presented view controller and successfully pushes view controller. The problem is with transitions only. 2)read the question carefully - I can change `viewControllers` as I wish and then call push/pop. And it will work. The problem is with modal presentation by itself – Vyachaslav Gerchicov Aug 16 '21 at 10:26

2 Answers2

0

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)
}
 
Aura
  • 246
  • 1
  • 10
  • no suitable for my situation, because "A presents D" also means D may be dismissed to A. Currently D is pushed (instead of presenting) but it makes troubles with dismissing D animation – Vyachaslav Gerchicov Aug 16 '21 at 12:42
0

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.

Vyachaslav Gerchicov
  • 2,317
  • 3
  • 23
  • 49