【发布时间】:2018-12-04 10:53:40
【问题描述】:
我正在尝试以编程方式快速创建自定义键盘,并且到目前为止能够在 iPhone 上为 portrait 和 landscape 创建我想要的约束,但只有当我以相应的方向启动键盘时。
当我自己翻转设备时出现问题:Portrait、Landscape。我已将我的约束存储在两个数组中,并在我的 viewDidLoad 和 viewWillTransition 函数中运行这段代码:
if UIScreen.main.bounds.height >= 568 {
NSLayoutConstraint.deactivate(constraintsLandscape)
NSLayoutConstraint.activate(constraintsPortrait)
}
else if UIScreen.main.bounds.height <= 414 {
NSLayoutConstraint.deactivate(constraintsPortrait)
NSLayoutConstraint.activate(constraintsLandscape)
}
对此的任何帮助表示赞赏。
【问题讨论】:
标签: ios iphone swift keyboard constraints