ios - 使用呈现的键盘弹出 UIViewController

标签 ios objective-c cocoa-touch uikit

我已经在其中创建了带有 UIScrollView 的 UIViewController。在 UIScrollView 中,我添加了一些 UITextFields 用于数据输入。当其中一个 UITextFields 成为 firstResponder(键盘出现在屏幕上)并且我试图用滑动手势弹出这个 UIViewController 时,我有以下效果:enter image description here

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/

相关文章:

iphone - iPhone:如何使用MACRO检查设备?

ios - 为什么在 iOS 8 中我的应用程序在启动时采用了错误的方向?

ios - NSURLSessionDownloadTaskDelegate JSON 响应

android - 将设备插件(和其他)手动安装到 cordova 3.0

ios - 在 iOS 中检测不活动(无用户交互)以显示单独的屏幕,如覆盖

iOS addSubview 不显示 View

ios - 自动居中 UIViews

Objective-C extern 和 typedef undefined symbol

objective-c - 指定核心数据属性的有效值

ios - 使用 IOS 发送 Twitter 请求