Post

Replies

Boosts

Views

Activity

Swift: popToRootViewController with animation bug
Recently, when I was working on my project, I would like to get the current displayed viewController by observing the navigationController delegate: func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) { print("Will show: \(viewController)") } Then, I noticed it was not the expected top viewController after calling popToRootViewController(animated: true). There are steps to reproduce: Create a new Xcode project and create viewControllers A,B,C(more than two viewControllers) Push A to B to C In ViewController C, trigger a button to pop to root viewController which function named "navigationController?.popToRootViewController(animated: true)" Before step 3, the navigation stack is like [A, B, C], but After step 3 , the navigation stack is like [C, A] not as expected result that just remain the top viewController [A]. But if I disable the pop animation as "false", it would be only top viewController [A]. I think it's mostly like an Apple internal bug?
0
3
456
Mar ’22