0
첫 번째 구성 요소의 선택기보기에서 날짜를 사용하려고합니다. 다른 배열에 다른 구성 요소를 사용하고 싶습니다.첫 번째 구성 요소에 대한 UI 픽커보기에서 날짜를 사용하고 싶습니다.
도와주세요 ... 감사합니다.
첫 번째 구성 요소의 선택기보기에서 날짜를 사용하려고합니다. 다른 배열에 다른 구성 요소를 사용하고 싶습니다.첫 번째 구성 요소에 대한 UI 픽커보기에서 날짜를 사용하고 싶습니다.
도와주세요 ... 감사합니다.
2 개의 어레이가 필요합니다. 다음과 같이 두 개의 구성 요소에서 사용할 두 개의 배열을 선언하고 채 웁니다.
NSArray *firstComponentArray = // populate the first array here
NSArray *secondComponetArray = // populate the second array here
.
.
.
- (NSInteger) numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
// return the number of components do you need
}
// return the right number of items in picker view delegate: numberOfRowsInComponent
- (NSInteger) pickerView:(UIPickerView *)pickerView numberOfRowsInComponent(NSInteger)component
{
// first component
if (component == 0)
// return the count of the first array
// second component
else
//return the count of the second array
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
// first component
if (component == 0)
// return the content of the first array at index using row
// second component
else
// return the content of the second array at index using row
}
마찬가지로 우리는 배열 오른쪽에서 추가 할 수 있으므로 배열에 같은 모든 날짜를 추가하고 싶습니다. –