问题
I have an "issue" with my NavigationController. Actually it seems to me, that this behavior seems to be intended.
My App uses a SplitViewController, using a TableViewController for the MasterView and a NavigationController for the DetailView.
I have 4 views, which i can switch from each to another. What I observed is that every time I use one of the NavigationController buttons to change the View the memory consumption increases by almost 1.5MB.
Using the back-button of the NavigationController the views seem to get released correctly as the used memory decreases.
I read that the views are put on a stack every time i switch them, but actually that is not what I need (At least I hope so, because at a certain degree I rely on the viewdidload-method to update the content, which I pass via NSNotification to each view. At that point it would be nice if all views could share that passed userInfo, but that's a different story...).
So what I'm looking for is a way to replace the newest ViewController on the NavigationController view stack by the one. I don't need a history of like 100 views where like 40 views always are actually the same. I only found answers about memory not getting released after using the back button. Therefore I assume the current behavior is the intended one.
回答1:
what I'm looking for is a way to replace the newest ViewController on the NavigationController view stack by the one
setViewControllers:animated: lets you construct the stack however you like.
https://developer.apple.com/library/ios/documentation/uikit/reference/UINavigationController_Class/Reference/Reference.html#//apple_ref/occ/instm/UINavigationController/setViewControllers:animated:
来源:https://stackoverflow.com/questions/23846686/memorymanagement-with-uinavigationcontroller