如何在iOS的UIDatePicker中屏蔽日期 [英] How to block days in UIDatePicker for iOS
本文介绍了如何在iOS的UIDatePicker中屏蔽日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
谢谢。
解决方案
你可以做的只是添加一个自定义的UIPickerView,如注释中所述,或者实现一个方法,调用事件 UIControlEventValueChanged
描述了 here
然后检查一个有效的工作日的新值。您可以通过以下方式获得工作日:
NSCalendar * calendar = [NSCalendar currentCalendar];
NSDateComponents * components = [日历组件:NSWeekdayCalendarUnit fromDate:[NSDate date]];
return [components weekday]; // 1 =星期日,2 =星期一...
没有办法隐藏几天在滚轮中。
I'm using a Date picker on my IOS app, and I want to know if is possible to block some days. For example, I need to block all mondays from a year, is this possible?
Thanks.
解决方案
The only thing you can do is add a custom UIPickerView as described in the comments or implement a method that is called for the event UIControlEventValueChanged
as described here
then check the new value for a valid weekday. you can get the weekday with:
NSCalendar* calendar = [NSCalendar currentCalendar];
NSDateComponents* components = [calendar components:NSWeekdayCalendarUnit fromDate:[NSDate date]];
return [components weekday]; // 1 = Sunday, 2 = Monday, ...
There is no way to hide some days in the scrollwheel.
这篇关于如何在iOS的UIDatePicker中屏蔽日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文