我是 Xcode 的新手。我正在尝试在一个视图中构建两个 UIPickerView。第一个 UIPickerView 中的数据如期而至,但我无法在第二个 UIPickerView 中获取数据。一个选择器有一个组件,另一个有两个组件。
- (NSInteger)numberOfComponentsInPickerView:
(UIPickerView *)pickerView
{
if (pickerView == showData)
return 1;
else
return 2;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView
numberOfRowsInComponent:(NSInteger)component
{
if (pickerView == showData)
switch (tapButton) {
case 1:
return [countryData count];
break;
case 2:
return [serviceData count];
break;
case 3:
return [budgetData count];
break;
default:
return 0;
}
else {
if (component == 0)
return [hourTime count];
else
return [minuteTime count];
}
}
- (NSString *)pickerView:(UIPickerView *)pickerView
titleForRow:(NSInteger)row
forComponent:(NSInteger)component
{
if (pickerView == showData)
switch(tapButton)
{
case 1:
return [countryData objectAtIndex:row];
break;
case 2:
return [serviceData objectAtIndex:row];
break;
case 3:
return [budgetData objectAtIndex:row];
break;
default:
return @"nothing";
}
else {
if (component == 0)
return [hourTime objectAtIndex:row];
else
return [minuteTime objectAtIndex:row];
}
}