本文介绍了选择视图0时,UIDatePicker设置为1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用相同的 UIDatePicker 实例来设置三个不同的值。其中两个是日期,最后一个是时间(例如1:05)。

I'm using the same UIDatePicker instance to set three different values. Two of them are dates and the last is a time (e.g. 1:05).

我的问题是关于使用 UIDatePicker 当设置在模式 UIDatePickerModeCountDownTimer 时。首先,设置在此模式下, date 属性将被忽略,并且必须使用 countDownDuration 来获取该值。在我的情况下,将选择器设置为此模式后,日期不会被忽略

the property is correctly set, I simply not correctly logged it (%@ modifier was used instead of %f); my next issue remains though.

最糟糕的是,日期设置正确,但不幸的是,当我选择0:00。此时,日期设置为0:01!

The worst thing is that the date is correctly set but unfortunately not when I select 0:00. For this time, the date is set to 0:01!

任何帮助?我缺少什么?

Any help? What am I missing?

推荐答案

倒计时器用于设置倒计时的时间。所以,零没有任何意义。显然,最小值被限制为1分钟。

The count-down timer is intended for setting a time for count-down. So, zero simply makes no sense. Obviously the minimum value is constrained to 1 minute.

虽然有一个奇怪的行为:如果将定时器的间隔设置为超过1分钟,您可以选择0,但在你的代码中得到1。当间隔为1分钟时,您会注意到您不能在选择器中选择0分钟;它反弹。我认为以前的行为是一个错误。您不应该选择0分钟,无论间隔时间有多大。

There is one strange behavior though: if you set the interval for the timer to more than 1 minute, you are able to select 0, but get 1 inside your code. When the interval is 1 minute, you notice that you cannot select 0 minutes in the picker; it snaps back. I consider the former behavior a bug. You should never be able to select 0 minutes, no matter how big the interval is.

这篇关于选择视图0时,UIDatePicker设置为1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 02:41