简体   繁体   中英

iPhone Does releasing modal view controller also pop pushed controllers onto stack?

Lets say you present modal view controller (which is navigation controller) and push onto navigation stack 3-4 view controllers. Would dismissing modal view controller also pop these controllers from navigation stack, or will they continue to linger in memory?

I apple doc it states that when presenting multiple modal view controllers, if you dismiss the root one, all other will be dismissed, but animation of dismissal will happen only once. There is, however, no mention, what if you had pushed some controllers on modal view controller and then dismissed it.

When you dismiss the modal view controller, it will be deallocated from memory. So unless you keep a reference to it, everything will be removed, including its inner view controllers in the stack.

However, if you do keep a reference to it, it will stay alive when dismissed, therefore keeping its current state. Next time you present it, it will be just as you left it.

The navigation controller contains the view controllers that are pushed within it. So when the navigation controller is presented modally and then dismissed, it's (contained) view controller stack gets cleaned up, too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM