我有一个UIPickerView
,有4列/组件。
我希望其他3个组件被禁用,或者当其中一个组件正在旋转时,它们无法接受来自用户的交互。
关于如何实现这一目标的任何建议?感谢。
编辑:添加示例代码,如下所示:
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
NSInteger rs1 = [pickerView selectedRowInComponent:0];
NSInteger rs2 = [pickerView selectedRowInComponent:1];
NSInteger rs3 = [pickerView selectedRowInComponent:2];
NSInteger rs4 = [pickerView selectedRowInComponent:3];
NSLog(@"selected: %d %d %d %d",rs1, rs2, rs3, rs4);
}
// returns the number of 'columns' to display.
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
return 4;
}
// returns the # of rows in each component..
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
return 10;
}
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view{
UIImageView *slotImage = [[UIImageView alloc] init];
if (component == 0) {
[slotImage setImage:...];
}else if (component == 1) {
[slotImage setImage:...];
}else if (component == 2) {
[slotImage setImage:...];
}else if (component == 3) {
[slotImage setImage:...];
}
return slotImage;
}