我正在制作一个自定义键盘,当移动设备的方向发生变化时,我必须在横向中隐藏一个按钮,请建议我该怎么做我正在使用下面的代码来完成这项任务,请帮助我。在横向中该按钮也是可见的 我想在横向上隐藏按钮并在纵向模式下可见
override func updateViewConstraints() {
super.updateViewConstraints()
// Add custom view sizing constraints here
var currentDevice: UIDevice = UIDevice.currentDevice()
var orientation: UIDeviceOrientation = currentDevice.orientation
if orientation.isLandscape {
button.hidden = true
}
if orientation.isPortrait {
button.hidden = false
}
}