Initialize height
class KeyboardViewController: UIInputViewController { override func updateViewConstraints() { super.updateViewConstraints() print("view update view"); } override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) print("view will appear"); self.inputView!.addConstraint(windowConstraintsHeight); } override func viewDidLoad() { super.viewDidLoad() //Check whether the pinyin is legal reference pinyin array //---- Set keyboard popup height------- let dummyView = UILabel(frame:CGRect.zero) dummyView.translatesAutoresizingMaskIntoConstraints = false; self.view.addSubview(dummyView); windowConstraintsHeight = NSLayoutConstraint( item:self.inputView!, attribute:.height, relatedBy:.equal, toItem:nil, attribute:.notAnAttribute, multiplier:0.0, constant:CGFloat(500))//500 is the keyboard height
Change the height in the middle
self.inputView?.removeConstraint(windowConstraintsHeight) windowConstraintsHeight = NSLayoutConstraint( item:self.inputView!, attribute:.height, relatedBy:.equal, toItem:nil, attribute:.notAnAttribute, multiplier:0.0, constant:CGFloat(800)) // self.viewWillAppear(true); self.updateViewConstraints(); //The main window jumps to another View(ViewController(),) self.present(ViewController(), animated: true, completion: nil);