在我们的应用程序中,我们有一个UIPickerView,让您选择一个季节。然而,在iOS 11上,“完成”按钮和“取消”按钮消失了,只有在切换应用程序时才可见。有其他人经历过这种情况吗?
附带iOS 11行为的截图,下面是iOS 10的行为。
编辑:这里有一个有问题的完整示例应用程序:
这是设置选择器视图的代码。
附带iOS 11行为的截图,下面是iOS 10的行为。
编辑:这里有一个有问题的完整示例应用程序:
这是设置选择器视图的代码。
func setUpPickerView(){
self.seasonPicker = UIPickerView.init(frame: CGRect.init(x: 0, y: 50, width: self.frame.width, height: UIScreen.main.bounds.height / 3))
self.seasonPicker.delegate = self
self.seasonPicker.dataSource = self
self.seasonTextField.inputView = self.seasonPicker
let toolbar = UIToolbar.init(frame: CGRect.init(x: 0, y: 0, width: self.frame.width, height: 50))
toolbar.barStyle = UIBarStyle.default
let labelTitle = UILabel.init(frame: CGRect.init(x: 0, y: 50, width: 150, height: 20))
labelTitle.backgroundColor = UIColor.clear
labelTitle.textColor = UIColor.black
labelTitle.textAlignment = NSTextAlignment.left
labelTitle.text = "Select a Season"
labelTitle.sizeToFit()
let typeFeild = UIBarButtonItem.init(customView: labelTitle)
let cancelButton = UIBarButtonItem.init(title: "Cancel", style: UIBarButtonItemStyle.plain, target: self, action: #selector(didClickPickerCancel))
let flexSpace = UIBarButtonItem.init(barButtonSystemItem: UIBarButtonSystemItem.flexibleSpace, target: nil, action: nil)
let doneButton = UIBarButtonItem.init(title: "Done", style: UIBarButtonItemStyle.plain, target: self, action: #selector(didClickPickerDone))
toolbar.items = [cancelButton, flexSpace, typeFeild, flexSpace, doneButton]
toolbar.sizeToFit()
self.seasonTextField.inputAccessoryView = toolbar
}