0
votes

I have a main UINavigationController for the App and now I wanted to present another navigationController for another flow. After completing the flow, I'm dismissing the another NavigationCotnroller but the rootViewController of another NavigationController is not getting deallocated.('deinit' is not getting called on rootViewController of another navigation controller).

below is example code to understand -

// main Navigation controller for the app
let navigationController = UINavigationController()

//another navigation controller to present separate flow of screens
let rootController = UIViewController()
let subNavigationController = UINavigationController(rootViewController: rootController)
navigationController.present(subNavigationController, animated: true, completion: nil)

//while dismiss - deinit on rootController is not getting called
navigationController.dismiss(animated: true, completion: nil)
1
Don't you think you first you should find the rootview controller of navigationController and then do something like this? navigationController.viewcontrollers?.first?.navigationController?.dismiss(animated: true)CrackIt
@CrackIt I've tried to dismiss like that too. I have tried to dismiss from mainNavigationController, subNavigationController and rootViewController of subNavigationController but result is the same.Saurabh Prajapati
can you share the actual code?CrackIt
This is the actual copy of the code! I'm using the same code just with different naming conventionsSaurabh Prajapati
try rootController.navigationController?.dismiss(animated : true)CrackIt

1 Answers

0
votes

In this exemple, the rootViewController is retain by the let declaration.