0

I made some views ordering like Login -> Navigation Controller[Dashboard -> Detail]

In LoginViewController, There is Login Button and it has Action

@IBAction func loginTapped(_ sender: Any){
    let mainNavigationController = storyboard?.instantiateViewController(withIdentifier: "MainNavigationViewController") as! MainNavigationViewController
    present(mainNavigationController, animated: true, completion: nil)
}

In NagivationController

There are two Views,Dashboard and Detail

Detail View is pushed by segue action from Dashboard

and Dashboard has tab bar Item to logout

I know that when back button is tapped in Detail view, It doesn't deallocating Detail View. It just push back to Navigation Controller's Stack (Is it right...?)

but when i tapped Logout Button in Dashboard, I thought Navigation Controller which contains two views (Dashboard, Detail) should be deallocated

but it doesn't deallocated.

I set the deinit method in Navigation View Controller like this

deinit {
    print("Main Navigation View Controller is deinited")
}

but it never called

How can i deallocate views that appear after login, when i tapped logout button

Sorry for poor syntax in English because i'm not Native

PrepareFor
  • 2,448
  • 6
  • 22
  • 36
  • going back from the detail view should deallocate it unless something else is holding a strong reference to it. What code do you run when the logout button is tapped? Again, if you are dismissing the navigation controller correctly, it and and the dashboard view controller will be deallocated – Paulw11 Oct 20 '17 at 13:34
  • @Paulw11 i use`presentingViewController?.dismiss(animated: true, completion: nil) ` – PrepareFor Oct 20 '17 at 13:35

0 Answers0