我已经在其中创建了带有 UIScrollView 的 UIViewController。在 UIScrollView 中,我添加了一些 UITextFields 用于数据输入。当其中一个 UITextFields 成为 firstResponder(键盘出现在屏幕上)并且我试图用滑动手势弹出这个 UIViewController 时,我有以下效果:
UIViewController 的 View 正在下降,我可能会在当前的 UIViewController 中看到以前的 UIViewController 的部分。你有什么想法,如何解决这个问题?
最佳答案
我发现当使用自定义后退 Action 时,交互式弹出手势停止工作。
要解决此问题,您可以将 interactivePopGestureRecognizer.delegate 属性设置为 nil。
试试这个:
class NavigationController: UINavigationController, UIGestureRecognizerDelegate {
/// Custom back buttons disable the interactive pop animation
/// To enable it back we set the recognizer to `self`
override func viewDidLoad() {
super.viewDidLoad()
interactivePopGestureRecognizer?.delegate = self
}
func gestureRecognizerShouldBegin(gestureRecognizer: UIGestureRecognizer) -> Bool {
return viewControllers.count > 1
}
}
关于ios - 使用呈现的键盘弹出 UIViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55187724/