如何获取“countDownDuration”的值UIDatePickerModeCountDownTimer 的?
我知道这个问题之前已经在这个论坛上发布过: 如何获取 UIDatePicker 的时间间隔UIDatePickerModeCountDownTimer 模式?
但是,其中提到的答案对我不起作用,我无法对之前的帖子发表评论,因此出现了这个新问题。
我有一个简单的应用程序,其中有一个处于 CountDownTimer 模式的 UIDatePicker。我想检索用户设置的任何值并将其存储或打印到日志。
- (IBAction) datePickerValueDidChange:(id)sender {
NSLog(@"datePicker.countDownDuration: %f", timerPicker.countDownDuration);
}
打印的值始终为 0。不知道我哪里出了问题,所以任何帮助将不胜感激。
I know this question has been posted on this forum before:
How do you get the time interval for UIDatePicker in UIDatePickerModeCountDownTimer mode?
However, the answer mentioned there isnt working for me and i am not able to comment on the earlier post hence this new question.
I have a simple application where i have a UIDatePicker in CountDownTimer mode. I want to retrieve whatever value the user sets it to and store it or print it to log.
- (IBAction) datePickerValueDidChange:(id)sender {
NSLog(@"datePicker.countDownDuration: %f", timerPicker.countDownDuration);
}
the value being printed is 0 always. Dnt know where i am going wrong so any help will be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您没有发布太多代码,但我猜测您的选择器的名称与
timerPicker
不同。或者,您的本地实例变量与您的选择器属性发生冲突,并且将其引用为 self.timerPicker.countDownDuration 即可解决问题。
第三种选择是您没有连接和/或声明您的 viewController 作为选择器的委托,或者如果您有,那么您没有在界面中包含委托声明(尽管后者不太可能,因为您应该得到一个明显的构建时错误)。
否则,您将需要发布更多代码,包括声明它的位置以及设置其值的位置。
You haven't posted much code, but my guess would be that your picker has a different name than
timerPicker
.Alternately you've got a local instance variable conflict with your picker property and that referring to it as
self.timerPicker.countDownDuration
will do the trick.A third option is that you've either not connected and/or declared your viewController as being the picker's delegate, or if you have then you haven't included the delegate declaration in your interface (though the latter is less likely because you should get a noticeable build-time error).
Otherwise you'll need to post some more code, including where you declare it and where you set its values.
看看这个,有关于带有日期选择器的倒计时器的完整教程 --- http://aarlangdi.blogspot.com .au希望这对你们有帮助
Check this out, there is full tutorial about count down timer with date picker --- http://aarlangdi.blogspot.com.au hope this is helpful to you guys