【发布时间】:2018-06-07 16:30:43
【问题描述】:
我将UIPickerView 作为UITextField 的输入,并使用“完成”按钮实现UIToolbar。它工作得很好,但是当我在 iPhone 上切换到横向模式时,UIToolbar 消失了。这是我的代码:
override func viewDidLoad() {
super.viewDidLoad()
thePicker.delegate = self
let toolBar = UIToolbar()
toolBar.barStyle = UIBarStyle.default
toolBar.isTranslucent = true
toolBar.tintColor = UIColor(red: 76/255, green: 100/255, blue: 217/255, alpha: 1)
toolBar.sizeToFit()
let doneButton = UIBarButtonItem(title: "Aceptar", style: UIBarButtonItemStyle.plain, target: self, action: #selector(doneClick))
toolBar.setItems([doneButton], animated: false)
toolBar.isUserInteractionEnabled = true
testTextField.inputView = thePicker
testTextField.inputAccessoryView = toolBar
}
【问题讨论】:
标签: ios swift uipickerview uitoolbar