开发者

How to limit UIPickerView or UIDatePickerView values?

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 fr开发者_Go百科om 1981 and show values till present date & time the app is running.


UIDatePicker has a property for the minimumDate Setting this will disallow selection before that time. It also has maximumDate set that to [NSDate date] and it will allow selection up until 'now'


For UIDatePicker you have maximumDate and minimumDate 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜