UIDatePicker:时间模式:初始化时间(一定要简单)
所有,
这似乎是一个简单的事情,但我找不到*正确的方法来创建 UIDatePicker,在时间模式下,并将其初始化为特定时间。我不需要日期——只是时间(想想闹钟)。我创建了一个 NSDate 对象:
NSDate * date = [[NSDate alloc] initWithTimeIntervalSinceReferenceDate: (NSTimeInterval) delta];
pickerView = [[UIDatePicker alloc] init]; // which should be 'now' right?
pickerView.datePickerMode = UIDatePickerModeTime; // which creates just the clock
[pickerView setDate:date];
在第一行中,间隔(增量)为零。显示 7:00PM。
这一定很简单,我错过了,但我找不到正确的方法——有人吗?
先感谢您!
:bp:
*是的,我看过了,但显然不在正确的地方:(
All,
This seems like such a simple thing, but I cannot find* the right method to create a UIDatePicker, in time mode, and have it initialized to a specific time. I don't want date -- just time (think alarm clock). I have created a NSDate object:
NSDate * date = [[NSDate alloc] initWithTimeIntervalSinceReferenceDate: (NSTimeInterval) delta];
pickerView = [[UIDatePicker alloc] init]; // which should be 'now' right?
pickerView.datePickerMode = UIDatePickerModeTime; // which creates just the clock
[pickerView setDate:date];
and in the first line, the interval (delta) is zero. It displays 7:00PM.
This has gotta be so simple that I'm missing it, but I can't find the right way -- anyone?
Thank you in advance!
:bp:
*yes, I have looked, but apparently not in the correct places :(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
考虑时区。仅当您处于 UTC 时,您才会得到 0AM。
Take the time zone into account. You will get 0AM only if you are at UTC.
谢谢你 dkk——我很感谢你的帮助。真正的答案是不使用 DatePicker,而是使用 PickerView(不带日期)。这让事情变得更简单、更可行。
再次感谢。
Thank you dkk -- I appreciate your help. The real answer was to not use a DatePicker, but to use a PickerView (w/o the date). That made things simpler and do-able.
Thanks again.
这里涉及日期的步骤是
这适用于
UIDatePicker
,datePickerMode
为UIDatePickerModeTime
&UIDatePickerModeCountDownTimer
The steps here with the date are
This works for
UIDatePicker
withdatePickerMode
ofUIDatePickerModeTime
&UIDatePickerModeCountDownTimer