我正在尝试在第一个组件的选择器视图中使用日期。我想使用另一个组件与另一个数组。
请帮帮我......谢谢
答案 0 :(得分:0)
你需要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
}