[英]How can i select the complete row for different components in UIPickerView?
我在PickerView中有4个组件。 当选择组件0的第0行时,我想在所有组件中选择完整的行。 同样,对于每个组件的每隔一行。 有什么办法可以扩展所有人的单一选择吗?
任何帮助,将不胜感激。
实现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个组件就没有多大意义。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.