如果我有一个包含三个组件(表盘)的 UIPickerView。拾取器如何处理同时旋转的两个转盘?例如,用户可能会轻弹第一个转盘,它会自由旋转,然后立即缓慢地单击第二个转盘上的选项。
我正在选择器中执行以下操作。如果一个转盘在旋转,我就无法捕捉到它的值。我仅在转盘一次旋转一个时捕获值。
- (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
if(component == 0){
dateEndCenturyText = (NSString *)[dateCentury objectAtIndex:row];
}
else if(component == 1){
dateEndDecadeText = (NSString *)[dateYear objectAtIndex:row];
}
else if(component == 2){
dateEndYearText = (NSString *)[dateYear objectAtIndex:row];
}
是否有更好的方法来确保即使两个转盘旋转也能捕获值?
最佳答案
对此最可靠的解决方案可能是每次事件触发时更新所有三个值。您可以使用以下方法检索 UIPickerView 中任何组件的选定行:
UIPickerView selectedRowInComponent:
Returns the index of the selected row in a given component
- (NSInteger)selectedRowInComponent:(NSInteger)component
希望这有帮助!
关于iphone - UIPickerView 如何处理 2 个以上的转盘旋转?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/661101/