如何判断 UINavigationControllerStack 中的后退按钮何时被按下
是否可以检查 UINavigationController 堆栈中何时按下后退按钮?我尝试将操作和目标添加到 self.navigationItem.backBarButtonItem 但无济于事。
有人有解决办法吗?
Is it possible to check when the back button is pressed in a UINavigationController stack? I've tried adding a action and target to self.navigationItem.backBarButtonItem to no avail.
Anyone have any solutions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你可以尝试我的方法:
在你的ViewController中写入:
和操作方法:
你必须拍一张你想要的后退按钮的照片。
viewController弹出时隐藏后退按钮的动画和iOS的动画不一样!
P/s:
我是从模拟器中得到的。希望有用! :)
You can try my way:
Write in your ViewController:
And action method:
You have to take a photo of back button you want.
Animation of hiding back button when viewController is popped is not the same animation of iOS!
P/s:
I've get it from simulator. Hope it useful! :)
解决这个问题的一种方法是重写 UIViewController 中的
viewWillDisappear
,该控制器在按下后退按钮时可见:显然,这不会直接拦截后退按钮本身的按下,但它为您提供了那时有机会执行逻辑。
One way to get at this would be to override
viewWillDisappear
in the UIViewController that is visible when the back button is pressed:Obviously this doesn't directly intercept the press on the back button itself, but it gives you a chance to perform logic at that time.