【发布时间】:2017-09-19 09:09:30
【问题描述】:
我将我的项目更新为 Swift 4 XCode 9
我有一个 InputText 使用 Picker 的输入视图
我在 InputText 添加了一个UIToolBar。
它在升级之前运行良好。
现在它就像UIPickerView 它在UIToolBar 之上。
我可以看到但如果我点击它就像我点击UIPickerView
UIToolBar 运行良好,因为如果我将工具栏设置为普通的 TextInput,它就会出现并且运行良好..
可能是什么?
这是我的代码:
var picker: UIPickerView
picker = UIPickerView(frame: CGRect(x: 0, y: 200, width: view.frame.width, height: 300))
picker.backgroundColor = .white
picker.showsSelectionIndicator = true
picker.delegate = self
picker.dataSource = PickerData as? UIPickerViewDataSource
textField.inputView = picker
let toolBar = UIToolbar()
toolBar.barStyle = UIBarStyle.default
toolBar.isTranslucent = true
toolBar.tintColor = .blue
toolBar.sizeToFit()
let doneButton = UIBarButtonItem(title: "Seleziona", style: UIBarButtonItemStyle.plain, target: self, action: #selector(self.doneFunction(_:)))
let spaceButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.flexibleSpace, target: nil, action: nil)
let cancelButton = UIBarButtonItem(title: "Annulla", style: UIBarButtonItemStyle.plain, target: self, action: #selector(self.doneFunction(_:)))
toolBar.setItems([cancelButton, spaceButton, doneButton], animated: false)
toolBar.isUserInteractionEnabled = true
textField.inputAccessoryView = toolBar
我也尝试了picker.addSubview(toolBar),但结果相同。
【问题讨论】:
标签: uipickerview uitoolbar swift4 xcode9