2017-09-26 72 views
1

我正面临着一个奇怪的问题。我用下面的代码创建了UIPicker。我还使用IQKeyboardManager来管理键盘。工具栏和选取器之间的差距?

let datepicker = UIPickerView() 

     datepicker.frame = CGRect(x: 0, y: -10, width: UIScreen.main.bounds.width, height: 200) 
     datepicker.backgroundColor = Constants.Colors.blue 
     datepicker.tintColor = UIColor.white 
     textfieldDropDown.inputView = datepicker 
     textfieldDropDown.inputView?.autoresizingMask = .flexibleHeight 
     datepicker.delegate = self 
     datepicker.reloadAllComponents() 

enter image description here

临时溶液 如果我将高度设置为220,然后它不显示,因为更多的高度的任何间隙。

请告诉我这个最好的解决方案?

回答

1

datePicker.translatesAutoresizingMaskIntoConstraints =假

+0

感谢,但这并没有为我工作,所以我所做的是增加高度 – Techiee

1

有一个在iOS的11到选择器的更新,以解决它首先是改变你的

[[UIPickerView alloc] initWithFrame:CGRectMake(0, 100, self.view.frame.size.width, 200)] 

[UIPickerView new] 

也改变

[[UIToolbar alloc] init] 

[UIToolbar new] 

最后,

YOURTEXTFIELD.translatesAutoresizingMaskIntoConstraints = true;