0

I want to dismiss current view controller and show new view controller.

For example, a chatting application needs view controller for making chat room.

Let main view controller is A and view controller making chat room is B and chatting room is C.

When make new chat room, I have to go B and create then automatically present C. But when I dismiss C, I want to go A not B.

You may say "Oh, unwind can solve your problem!", but that's not I want.
I want to delete useless middle viewcontroller B.

And I saw article below

How to dismiss the current ViewController and go to another View in Swift

But for me, it doesn't work. It just dismiss or just present new view controller or present view controller and dismiss it as soon as show it.

Please help me!

Community
  • 1
  • 1
JoonSoo Park
  • 43
  • 12

2 Answers2

0

You can use button to comback from C to A.

Or you dissmiss C and in deletage of C in B, you detect when C dissmissed, you also dissmiss B.

iThanh
  • 121
  • 1
  • 7
  • Is the only option?? Even if I don't need viewcontroller B, even if it is useless, I have to keep it?? In android I can finish activity and start activity, not in swift? – JoonSoo Park Jul 23 '16 at 15:05
  • another, you can't dissmiss any view, just present view that you want. – iThanh Jul 23 '16 at 20:56
0

If I correct understand, you can save A controller reference for example in AppDelegate:

    var ANavigationController: UINavigationController?

and then create custom segue, where destination controller will be ANavigationController

Daniel Kuta
  • 1,634
  • 15
  • 24