iOS 11上的UIPickerView已更改?

Ste*_*Ojo 4 ios ios11

在我们的应用程序中,我们有一个UIPickerView,可以让您选择一个季节.但是,在iOS 11上," 完成"按钮和" 取消"按钮消失,只有在应用程序之间切换时才可见.还有其他人经历过这个吗?

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

}
Run Code Online (Sandbox Code Playgroud)

缺少完成按钮的UIPickerView 在视图之间切换时,UIPickerView的完成按钮会重新出现 UIPickerView在iOS 10上按预期工作

Ste*_*Ojo 10

原来有一个简单的解决方法:

self.seasonPicker.translatesAutoresizingMaskIntoConstraints = false
Run Code Online (Sandbox Code Playgroud)

在内部,看起来他们已经改变了输入附件视图的行为以默认启用此属性.