【问题标题】:how to select the specific value from UIpickerView如何从 UIpickerView 中选择特定值
【发布时间】:2012-05-14 13:42:27
【问题描述】:

我正在开发一个应用程序。在该应用程序中,我使用具有 10 个值的选择器视图。每当我向下滚动选择器时,在选择器弯下最后一个值后将被选中,并且 selectrow 将被触发。但我不希望那样一个,我需要选择我要选择的那个。所以请告诉我如何做那个。

【问题讨论】:

    标签: iphone


    【解决方案1】:

    UIPickerViewDelegate 方法可以为您提供选定的行:

    -(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row
    inComponent:(NSInteger)component
    {
            float rate = [[exchangeRates objectAtIndex:row] floatValue];
            float dollars = [dollarText.text floatValue];
            float result = dollars * rate;
    
            NSString *resultString = [[NSString alloc] initWithFormat:
            @"%.2f USD = %.2f %@", dollars, result,
                   [countryNames objectAtIndex:row]];
            resultLabel.text = resultString;
    }
    

    对于您的问题,这可能是正确的链接Click here

    【讨论】:

    • 可能你无法理解我的问题。如果我滚动选择器,那么上面的方法将被触发并选择一个值。但我不需要那个值。我不需要那个自动值选择.
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-03-22
    • 1970-01-01
    • 2020-07-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多