简体   繁体   English

对UITextField的inputView使用约束

[英]Using constrain for inputView of a UITextField

I have a UITextField and I added inputview to it 我有一个UITextField并向其中添加了inputview

 [textField setInputView:inputView];

I added some buttons along with date picker in input view. 我在输入视图中添加了一些按钮以及日期选择器。 Input view has UIDatePicker as subview. 输入视图具有UIDatePicker作为子视图。 Since the inputview is not added as subview to any other view, I cannot set height constrain for inputView. 由于未将inputview作为子视图添加到任何其他视图,因此无法为inputView设置高度限制。 How to deal with constrain for inputview of a UITextField . 如何处理UITextField inputview的约束。

I think you not need to set constraint for input view. 我认为您不需要为输入视图设置约束。 because it is take default place of keyboard . 因为它是keyboard默认位置。

You should show date picker as input view and you should take toolbar as inputaccessory view of textfield and add buttons to that tool bar ,so you not need to manage layout and it is the standard way also. 您应该将日期选择器显示为输入视图,并应将工具栏作为inputaccessory view输入inputaccessory view ,并向该tool bar添加按钮,因此您无需管理布局,这也是标准方法。

Hope this will help :) 希望这会有所帮助:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM