问题描述
假设我有 UIViewController
A和B.
用户使用push segue从A导航到B.
比用户按下后退按钮并进入A.
Say I have UIViewController
A and B.User navigates from A to B with a push segue. Than user presses back button and comes to A.
现在调用A的 viewWillAppear
。我可以在这里的代码中知道我来自后退按钮( navigationController popTo ...
)而不是通过其他方式?而且无需在B视图控制器中编写特殊代码。
Now viewWillAppear
of A is called. Can I know in the code here that I came from back button (navigationController popTo...
) and not by another way? And without writing special code in the B view controller.
推荐答案
嗯,也许你可以在<$中使用 self.isMovingToParentViewController
c $ c> viewWillAppear ,请参阅,如果是 NO
则表示当前视图控制器已经在导航堆栈上。
hm, maybe you can use self.isMovingToParentViewController
in viewWillAppear
, see docs, if it is NO
then it means the current view controller is already on the navigation stack.
这篇关于我可以在viewWillAppear中知道它是在navigationController pop(后退按钮)之后调用的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!