Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/111.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 我可以定制一个日期选择器吗?_Iphone_Ios_Ipad_Uidatepicker - Fatal编程技术网

Iphone 我可以定制一个日期选择器吗?

Iphone 我可以定制一个日期选择器吗?,iphone,ios,ipad,uidatepicker,Iphone,Ios,Ipad,Uidatepicker,可能重复: 我需要自定义UIDatePicker,因为我们支持多种日期格式,如dd-MM-yyyyy,dd-MM-yyyy HH:MM:ss,dd-MM 例如,在“日期和时间”选择器模式下,选择器中没有用于年份部分的辊。因此,提供的选择器模式是不够的 是否有任何方法可以自定义所需格式的日期选择器。aUIDatePicker支持中详述的四个datePickerMode常量。您不能提供自定义日期格式。但是,根据您的应用程序和要求,您可以使用标准的选择器视图:我只需要显示月份列表就可以了。绝对可以!

可能重复:

我需要自定义UIDatePicker,因为我们支持多种日期格式,如
dd-MM-yyyyy
dd-MM-yyyy HH:MM:ss
dd-MM

例如,在“日期和时间”选择器模式下,选择器中没有用于年份部分的辊。因此,提供的选择器模式是不够的


是否有任何方法可以自定义所需格式的日期选择器。

a
UIDatePicker
支持中详述的四个
datePickerMode
常量。您不能提供自定义日期格式。但是,根据您的应用程序和要求,您可以使用标准的选择器视图:我只需要显示月份列表就可以了。

绝对可以! 您不能使用
UIDatePicker
执行此操作,因为它仅支持4种日期格式,根据;但是,您可以使用
UIPickerView

您需要实现
UIPickerViewDelegate
方法,并为它们提供数据源,就像使用
UITableView
一样:

- (NSInteger)numberOfComponentsInPickerView: (UIPickerView*)thePickerView {
   return /* # of columns you need */;
}

- (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component
{
   return /* # of rows per component */;
}

- (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
   return /* date source/string/title for the row */;
}
参考: