答案 0 :(得分:2)
更新用于在此方法中填充第二个选择器的数组
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
if(pickerView == picker1)
{
// Update the array
pickerValuesArray2 = ...;
}
}
答案 1 :(得分:2)
我在我的项目中做了同样的事情。这是解决方案..
- (NSInteger)numberOfItemsInPickerView:(CPPickerView *)pickerView
{
if (pickerView.tag == 110)
{
return [picker_1_ary count];
}
else
{
return [picker_2_ary count];
}
}
- (NSString *)pickerView:(CPPickerView *)pickerView titleForItem:(NSInteger)item
{
if (thePickerView.tag == 110)
return [picker_1_ary objectAtIndex:item];
else
return [picker_2_ary objectAtIndex:item];
}
- (void)pickerView:(CPPickerView *)pickerView didSelectItem:(NSInteger)item
{
if (pickerView.tag == 110)
{
[picker_2 reloadAllComponents];
}
else
{
NSString *value = [[NSString alloc] initWithFormat:@"%@" , [picker_2_ary objectAtIndex:item]];
NSLog(@"Selected value ::: %@", value);
}
}
希望它有所帮助。谢谢..