iphone - UIPickerView 如何处理 2 个以上的转盘旋转?

标签 iphone cocoa-touch uipickerview

如果我有一个包含三个组件(表盘)的 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/

相关文章:

ios - 在 XCode 5 中应用程序窗口预计在应用程序启动结束时有一个 Root View Controller

iphone - 如何提示用户对您的 iPhone 应用程序进行评分,而无需等待他们删除该应用程序?

c++ - iOS 不合格 id 错误

iphone - 以编程方式将显示 image1 的 UIImageView 更改为 image2

iOS UIPickerView 自定义行 View 宽度错误

swift - UI 选择器 View 错误我尝试让它填充模型,

ios - UIPickerView 正在选择错误的行-Swift

iphone - 将用户发送到 Safari 并使用其在 iPhone 上配置的搜索提供程序执行搜索?

iphone - 如何为 UITextView 启用滑动手势

objective-c - 带有音频文件的 iPhone 应用程序太大了。如何减小尺寸?