Why the navigationBar/shouldPop is no more called?

Hi,

I had working code that catched the shouldPop event using the navigationBar delegate below, but it looks like since I upgraded to Xcode (12.2), it is no more working.

Am I facing an Apple bug or just something that I am doing wrong?

Code Block public func navigationBar(_ navigationBar: UINavigationBar, shouldPop item: UINavigationItem


Thanks
Answered by icarus_31 in 652353022
Finally, it was not working in debug mode. With Xcode debugger, the even was called!

To have full control and see the right behaviour in debug mode, we decided to change the way to handle it.

Doesn’t work

What do you get ? Error message ? Nothing (not called?)

this func must return a Bool.

Code Block func navigationBar(_ navigationBar: UINavigationBar,                   shouldPop item: UINavigationItem) -> Bool


Is it missing in your declaration or just in the copy in the thread ?
Did it solve the issue ?
Hi @Claude31,

The delegate is never called, so not much to say. The other 3 delegates though are still working.

Have you tried it with iOS14? If so, it is working?

Thanks
Accepted Answer
Finally, it was not working in debug mode. With Xcode debugger, the even was called!

To have full control and see the right behaviour in debug mode, we decided to change the way to handle it.

This is still an issue with Xcode 16.2 and iOS 18.2.

The UINavigationBarDelegate method navigationBar(_:shouldPop:) is not called as expected when running an app in debug mode / with "debug executable" checked (attached to Xcode). It works as expected and according to documentation only in release builds or when unchecking "debug executable" in Product -> Scheme -> Edit Scheme… -> Run -> Info

This issue causes confusion during development and testing.

Perhaps the accepted answer should not be accepted, since it is still an issue (that it doesn't work according to documentation in debug mode)?

Why the navigationBar/shouldPop is no more called?
 
 
Q