2012-12-18 2 views
0

가능한 중복 :
How to customize the UIDatePickerUIDatePicker를 사용자 정의 할 수 있습니까?

나는 우리가
dd-MM-yyyy, dd-MM-yyyy HH:mm:ss, dd-MM 같은 날짜 형식의 다양한 지원처럼 UIDatePicker을 사용자 정의 할 필요가있다.

예. "날짜와 시간"피커 모드에서는 피커에서 1 년 동안 롤러가 없습니다. 제공된 피커 모드가 충분하지 않은 경우.

날짜 표시기를 원하는 형식으로 사용자 정의 할 수있는 방법이 있습니까?

답변

0

물론입니다! UIDatePicker Class Reference에 따르면이 형식은 4 가지 날짜 형식 만 지원하므로 UIDatePicker으로는이 작업을 수행 할 수 없습니다. 그러나 당신은 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 */; 
} 

참조 : here

1

UIDatePicker은 에 설명 된 4 개의 datePickerMode 상수를 지원합니다. 사용자 정의 날짜 형식을 제공 할 수 없습니다. 그러나 응용 프로그램과 요구 사항에 따라 표준 피커보기를 사용할 수 있습니다. 여기에서는 월 목록 만 표시하면됩니다.

관련 문제