UIDatePicker只显示月和日 [英] UIDatePicker show only month and day
问题描述
我想要一个 UIDatePicker
,用户可以选择一个月和一天,而不是一年。我知道闰年有一个额外的一天,所以为了简单,让我们把这一天离开。
有任何方法删除年列或有2个卷轴 $ d $ b 你不能使用UIDatePicker类,因为它支持这样做 - UIDatePicker只支持以下模式:
typedef enum {
UIDatePickerModeTime,
UIDatePickerModeDate,
UIDatePickerModeDateAndTime,
UIDatePickerModeCountDownTimer
} UIDatePickerMode;
创建实现UIPickerViewDelegate并创建自己的视图和控制器 - 此处在UIPickerView的选择栏中修正标签
I'd like to have a UIDatePicker
where the user can pick a month and a day but not the year. I'm aware that leap years have an extra day, so for simplicity, let's throw that day away.
Is there any way to remove the year column or have 2 reels with month/day that act like the UIDatePicker
(grey out days that don't exist in the selected month)?
You cannot use the UIDatePicker class as it stands to do this - The UIDatePicker only supports the following modes
typedef enum {
UIDatePickerModeTime,
UIDatePickerModeDate,
UIDatePickerModeDateAndTime,
UIDatePickerModeCountDownTimer
} UIDatePickerMode;
Create a view and controller that implement the UIPickerViewDelegate and create your own - you may find a little more detail here Fixed labels in the selection bar of a UIPickerView
这篇关于UIDatePicker只显示月和日的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!