如果我有一个带有三个组件(dials)的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];
}有没有更好的方法来确保即使两个刻度盘旋转也能捕获数值?
发布于 2009-03-19 19:25:33
最健壮的解决方案可能是在每次触发事件时更新所有这三个值。您可以使用以下方法检索UIPickerView表中任何组件的选定行:
UIPickerView selectedRowInComponent:
返回给定component
中选定行的索引
希望这能有所帮助!
https://stackoverflow.com/questions/661101
复制相似问题