实际上使用 UIDatePickerModeCountDownTimer 作为计时器
我只是想制作一个计时器。我想使用 UIDatePicker
的 UIDatePickerModeCountDownTimer
模式,这样当用户只需在选择器中选择 15 分钟时,它们就会传回显示该值的屏幕标签中包含 15 分钟,然后他们可以从中倒计时。
当我尝试从 DatePicker 获取值时,我意识到选择器会传回一个 NSTimeInterval ,该值以秒为单位获取当前时间:
UIDatePicker *pickerView = [[UIDatePicker alloc] init];
NSTimeInterval new = (NSTimeInterval)pickerView.countDownDuration;
所以我想要的就是知道用户选择的值,不是当前时间(以秒为单位)。
我正在尝试从 UIActionSheet
中呈现的 DatePicker 传回此数据...对正在发生的事情或我做错了什么有什么想法吗?
我只想要一个计时器!!!!!!!
I am just trying to make a timer. I would like to use UIDatePickerModeCountDownTimer
mode of the UIDatePicker
, so that when the user simply selects say 15 mins in the picker, they are passed back to a screen that shows the value of 15 mins in a label that they can then count down from.
As I have tried to get the value from the DatePicker, I realized that the picker passes back an NSTimeInterval
that gets the current time in seconds:
UIDatePicker *pickerView = [[UIDatePicker alloc] init];
NSTimeInterval new = (NSTimeInterval)pickerView.countDownDuration;
So all I want is to know the value that the user selected, not the current time in seconds.
I am trying to pass this data back from a DatePicker that is being presented in a UIActionSheet
...any thoughts about what is going on or what I am doing wrong?
I just want a timer!!!!!!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的代码缺少一行,您必须为 UIDatePicker 设置模式。完整的代码应该是:
然后如果您不知道如何将 NSTimeInterval (秒)转换为分钟,您可以使用 这个问题
Your code lacks a line, you have to set the mode for your UIDatePicker. The full code should be:
and then if you don't know how to convert your NSTimeInterval (seconds) to minutes, you can use this question