0

私はすでにピッカービューのreloadAllComponentsdidSelectRowに入れていますが、ピッカービューの位置を開始位置にリセットできません。多くのボタンの入力として1つのピッカービューを使用しているため、ユーザーがデータを選択した後にピッカービューを開始位置にリセットすることは可能ですか? どのコードをどこに書くべきか?

あなたが私の英語を理解してくれることを願っています。ありがとうございました。

既にコードを配置していますが、まだ pickerView の状態を開始位置に配置できません。

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
    year = [picker selectedRowInComponent:0];
    month = [picker selectedRowInComponent:1];
    day = [picker selectedRowInComponent:2];
    date = @"";
    if(viewPicker.tag == 1) {
        labelTime.text = [date stringByAppendingFormat:@"%d:%d:%d", year , month, day];
    else {
       ...
    }
    [picker selectRow:0 inComponent:0 animated:YES];
}
4

1 に答える 1

1

reloadAllComponentsメソッドは、データをピッカーと同期するためにデータソースにクエリを実行するだけです。「リセット」とは、ピッカーが現在の選択範囲を最初の行に移動することを意味する場合、次のように実行できます。

// Here we select the first row, in the first component with animation
// Customize it accordingly
[myPicker selectRow:0 inComponent:0 animated:YES];

注意してください。でこのメソッドを呼び出すとdidSelectRow、ユーザーが行を選択するたびに、ピッカーは自動的に最初の行に移動します...

于 2012-06-25T09:58:26.900 に答える