- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
为了在 UINavigationController
上按下后退按钮时执行一些验证。在网上搜索如何做到这一点后,我决定将 UINavigationController
子类化并实现 UINavigationBarDelegate
。
这是我的问题:只要我实际上没有实现 UINavigationBarDelegate 协议(protocol)的任何内容,它就会像我使用普通的 UINavigationController 时一样工作。但是当我只实现这个功能时:
func navigationBar(_ navigationBar: UINavigationBar,
shouldPop item: UINavigationItem) -> Bool {
print(#function)
return true
}
我可以在调试控制台中看到该函数实际上被调用了。但弹出并没有发生,只有后退按钮消失, View 保留在那里。我希望仅使用上面的功能,它仍然可以像以前一样工作(即 View 应该正常弹出)。
任何人都可以看到我丢失的东西吗?
最佳答案
您缺少弹出 View Controller ,请在代码中再添加一行 self.popViewController(animated: true)
func navigationBar(_ navigationBar: UINavigationBar,
shouldPop item: UINavigationItem) -> Bool {
print(#function)
self.popViewController(animated: true)
return true
}
关于ios - 导航栏 :shouldPop is not functioning as expected,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48818838/
我试图阻止某些 ViewController 返回。我已将 UINavigationController 子类化以进行一些 UI 自定义。我使 UINavigationController 子类符合
为了在 UINavigationController 上按下后退按钮时执行一些验证。在网上搜索如何做到这一点后,我决定将 UINavigationController 子类化并实现 UINavigat
我已将 Xcode 升级到 11,并且使用 UINavigationBarDelegate 协议(protocol)中的 shouldPop() 方法在我们的 iOS 应用程序的 iOS13 模拟器/
我是一名优秀的程序员,十分优秀!