UIDatePicker小时间间隔(NSCalendarUnit?) [英] UIDatePicker hours interval (NSCalendarUnit?)

查看:142
本文介绍了UIDatePicker小时间间隔(NSCalendarUnit?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试制作一个UIDatePicker,以便在6.00和17.00之间选择小时。其他时间不活动但仍然可见。
我认为可以通过设置选择器日历来完成,然后使用这个:

I'm trying to make a UIDatePicker wich is alowing to select hours only betwen 6.00 and 17.00. The other hours shall be inactive but still visible. I think it can be done with setting up the picker calendar and then use this:

- (NSRange)maximumRangeOfUnit:(NSCalendarUnit)unit

但我确定如何。

也许有人可以帮助我。

谢谢!

推荐答案

抱歉,UIDatePicker不支持设置有效的时间范围,如你所描述的。唯一的选择是最小和最大的日期。

Sorry, but UIDatePicker doesn't support setting valid time ranges like you describe. The only options are minimum and maximum dates.

您将需要从头开始构建一个自定义控件,或尝试将UIDatePicker子类化,但这不是一个路径推荐。

You'll either need to build a custom control from scratch or try to subclass UIDatePicker, but that's not a path I'd recommend.

这篇关于UIDatePicker小时间间隔(NSCalendarUnit?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆