如何限制 UIPickerView 或 UIDatePickerView 值?
所以我有一个UIDatePickerView
,通过它我可以获得用户的出生日期。 pickerView 具有无限时间(过去和未来)的选项。
我想要的是限制从 1981 年至今的 uipickervalues!
我不希望用户选择某个选项,然后弹出一个 UIAlertView 告诉该选项是错误的。
我该怎么办?我只想显示 1981 年以来的值并显示截至当前日期和日期的值应用程序运行的时间。
So I have a UIDatePickerView
through which I get the birth date of the user. The pickerView has options till infinite time (past and future).
What I want is to LIMIT the uipickervalues from 1981 till present date !
I do not want the user to select some option and then pop-up an UIAlertView telling that the option is wrong.
How can I go about this ? I just want to display values from 1981 and show values till present date & time the app is running.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于
UIDatePicker
,您有maximumDate
和您可以使用的minimumDate
属性。至于
UIPickerView
- 你是它的数据提供者,你可以完全决定在那里放什么以及以什么形式。请参阅其参考。For
UIDatePicker
you havemaximumDate
andminimumDate
properties that you can use.As for
UIPickerView
- you are its data provider and you can fully decide, what to put in there and in what form. See its reference.UIDatePicker
有一个minimumDate
属性,设置此属性将不允许在该时间之前进行选择。它还将maximumDate
设置为[NSDate date]
并且允许选择直到“现在”UIDatePicker
has a property for theminimumDate
Setting this will disallow selection before that time. It also hasmaximumDate
set that to[NSDate date]
and it will allow selection up until 'now'