Post

Replies

Boosts

Views

Activity

popToViewController inserts top view controller to the bottom
Hi all, hope ur doing well. Recently I found a strange behavior on UINavigationController popToViewController:animated:. I setup a dummy app with an UINavigationController and insert multiple UIViewControllers into it (no less than 4 view controllers). After that, I call [navigationController popToViewController:navigationController.viewControllers[0] animated:YES] to pop to the root view controller and monitors the status of navigationController.viewControllers instantly after it (in the same block). What I found is that UIKit instead of just popping all view controllers on top of the previous root view controller, it also inserts the previous top view controller to the bottom of the stack. This seems like a intermediate behavior and from the UI everything looks fine. Example: Before popTo: [A, B, C, D] Calling popTo: [navigationController popToViewController:navigationController.viewControllers[0] animated:YES] After popTo: [D, A] Would like to get some help to understand if this is an expected behavior and the reason. Thanks!
2
0
540
Jul ’23