简体   繁体   English

iOS 14.4 上的日期和时间选择器

[英]Date and time picker on iOS 14.4

I added Date picker view as keyboard controller on the UItextfiewld still now it was working properly but in latest version of iOS 14.4 getting date picker view very small.我在 UItextfield 上添加了日期选择器视图作为键盘控制器,现在它仍然可以正常工作,但是在最新版本的 iOS 14.4 中,日期选择器视图非常小。 here I am attaching the screenshot for it在这里,我附上了它的屏幕截图

在此处输入图片说明

How we can solve this in iOS 14.4 ?我们如何在 iOS 14.4 中解决这个问题?

Try to add this code programatically尝试以编程方式添加此代码

if #available(iOS 13.4, *) {
   self.datePicker.preferredDatePickerStyle = .wheels
}

Set preferdPickerStyle to your datepicker将 preferredPickerStyle 设置为您的日期选择器

if #available(iOS 13.4, *) {
  self.datePicker.preferredDatePickerStyle = .wheels
} else {
  // fallback to older version 
}

From iOS 14.4 or above iOS change the design for the date picker view so in that case if you want to continue showing older design you have to do code as per the iOS version.从 iOS 14.4 或更高版本 iOS 更改日期选择器视图的设计,因此在这种情况下,如果您想继续显示旧设计,则必须按照 iOS 版本执行代码。 and for that here is the version base condition code为此,这是版本基础条件代码

if #available(iOS 13.4, *) {
  self.datePicker.preferredDatePickerStyle = .wheels
}

here self.datepicker is your datePicker object这里self.datepicker是你的 datePicker 对象

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

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