How to retrict date on UIDatePickerView?

北城以北 提交于 2019-12-19 10:07:50

问题


hi guys can any body help me to figure out that how i can restrict the minimum date in UIDatePickerView? i tried to set property minumumDate from xib file but it is not working, even i set the the mode like this

[datePicker setDatePickerMode:UIDatePickerModeCountDownTimer];

but still it is not working. what i want to do is that user cannot scroll down from a specific date. example: if restricted date is 21.11.2011 then user should not scroll it to less then this date so please help me to figure it out

Thanx in advance


回答1:


I think you would want to set the mode to 'UIDatePickerDate', as 'UIDatePickerCountDownTimer' is meant to display a time. Have you tried:

[datePicker setDatePickerMode:UIDatePickerModeDate];
[datePicker setMinimumDate:minDate];

minDate would be an NSDate with the restricted date. For info on how to initialize this date, see here in the Apple documentation. Especially the part about date components.



来源:https://stackoverflow.com/questions/7857867/how-to-retrict-date-on-uidatepickerview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!