In SwiftUI, I'm trying to find a way to detect that a view is about to be removed only when using the default navigationBackButton
. Then perform some action.
Using onDisappear(perform:)
acts like viewDidDisappear(_:)
, and the action performs after another view appears.
Or, I was thinking the above problem might be solved by detecting when the default navigationBarBackButton
is pressed. But I've found no way to detect that.
Is there any solution to perform some action before another view appears?
(I already know it is possible to do that by creating a custom navigation back button to dismiss a view)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…