首页 > 解决方案 > 通过按钮用日期选择器替换 IOS 键盘

问题描述

我需要通过单击按钮用日期选择器替换已经打开的键盘!在互联网上搜索我只发现如何使用 datepicker 作为文本字段的输入。还有其他方法吗?谢谢!

标签: iosswiftkeyboarduidatepicker

解决方案


这应该用 UIDatePicker 替换键盘:

UIDatePicker *datePicker = [[UIDatePicker alloc] init];
[self.someTextField setInputView:datePicker];

确保您声明了 UIDatePicker:

class UIDatePicker : UIControl

可以在此处查看有关 UIDatePicker 的更多信息的文档。


推荐阅读