我目前正在为我的应用程序实现注册,我有 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/