我在 PickerView 中有 4 个组件。I want to select the complete row in all the components when row 0 of component 0 is selected. 同样,对于每个组件的每隔一行。有没有办法为所有人扩展单一选择?
任何帮助,将不胜感激。
我在 PickerView 中有 4 个组件。I want to select the complete row in all the components when row 0 of component 0 is selected. 同样,对于每个组件的每隔一行。有没有办法为所有人扩展单一选择?
任何帮助,将不胜感激。
实现UIPickerView
委托方法pickerView:didSelectRow:inComponent:
。
// called when a user selects a row
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
// This code assumes all four components have the same number of rows
for (NSInteger c = 0; c < pickerView.numberOfComponent; c++) {
if (c != component) {
[pickerView selectRow:row inComponent:c animated:NO]; // animate if desired
}
}
// do any other desired actions (if any) when a row is selected
}
另一种选择是只有一个组件在每行中显示所有四组数据。如果用户不能为每个组件选择不同的值,那么拥有 4 个组件就没有多大意义。