ios - 执行 segue 时隐藏键盘转换

标签 ios swift

我目前正在为我的应用程序实现注册,我有 3 个 ViewControllers 和一个文本字段。我想隐藏这些 View Controller 之间的任何键盘转换。

例如: 当我在 VC: A 时,我正在使用打开的键盘执行 segue 到 VC: B,然后其中一个新文本字段将成为第一响应者,并且可以看到一个小的键盘转换。 (首先,键盘关闭,然后键盘再次为新字段打开)。

那么我怎样才能为多个 View Controller 全局保持键盘打开?

最佳答案

这可能不是最好的方法,你可以像这样添加第二个 VC 作为 child

@IBAction func btnClicked(_ sender: Any) {

    let vc = self.storyboard?.instantiateViewController(withIdentifier: "dd") as! secViewController

    self.addChildViewController(vc)

     self.view.addSubview(vc.view)

    // illusion of push VC

    vc.view.frame = CGRect.init(x: self.view.frame.width, y: 0 , width: self.view.frame.width, height: self.view.frame.width)

    UIView.animate(withDuration: 0.5 , animations: {

              vc.view.frame = CGRect.init(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.width)

        }

     )

    vc.didMove(toParentViewController: self)

}

关于ios - 执行 segue 时隐藏键盘转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49610784/

相关文章:

ios - 使用 MKLocalSearchCompleter 搜索地名(城市/城镇)

ios - 如何向按钮添加一些功能?

ios - 我可以将一个或多个 SDK 集成到我自己的 iOS SDK 中吗?

swift - Swift 中忽略参数的用例是什么

ios - GameCenter - 在调用处理程序之前检查以前的登录?

iphone - 无法在 UITableView 上动态创建自定义单元格

ios - UIStepper不会显示

ios - 如果存在 UIApplicationLaunchOptionsLocationKey,则启动 Cordova iOS 应用程序

ios - 无法使用 cocoapods 安装 Firebase。它说 "Unable to get local issuer certificate"

swift - 分配对象时出现 Realm 错误