Ios5 调用selectRow:Incomonent:animated:method

Ios5 调用selectRow:Incomonent:animated:method,ios5,uipickerview,Ios5,Uipickerview,我的应用程序中有2个UIpicker视图,我希望Picker在我保存数据后显示最后选择的行。我正在使用这个selectRow:Incomonent:animated:method,但是我到底在哪里调用这个方法呢 在viewDidLoad中: if (self.pickerView == nil) { self.pickerView = [[UIPickerView alloc] init]; self.pickerView.delegate = self; self.pi

我的应用程序中有2个UIpicker视图,我希望Picker在我保存数据后显示最后选择的行。我正在使用这个selectRow:Incomonent:animated:method,但是我到底在哪里调用这个方法呢

在viewDidLoad中:

if (self.pickerView == nil) {
    self.pickerView = [[UIPickerView alloc] init];
    self.pickerView.delegate = self;
    self.pickerView.showsSelectionIndicator = YES;
在pickerView:viewForRow:forComponent:reusingView中:

if (component == 0)
        {
            for (int j =20; j<=200; j++)
            {
            NSString* myString           = [NSString stringWithFormat:@"%d",j];
            [myArray addObject:myString];
            }
            UILabel *weightLabel0        = [[UILabel alloc] initWithFrame:CGRectMake(40, 0, 100, 32)];
            Label0.text            = [myArray objectAtIndex:row];
            Label0.textAlignment   = UITextAlignmentLeft;
            Label0.backgroundColor = [UIColor clearColor];
            [rowView insertSubview:weightLabel0 atIndex:1];
return rowView;

        }

我应该如何把这些放在一起?例如,如果我在viewDidLoad调用此方法,则不会发生任何事情。请帮帮我()

我想出了一个主意。由于我的选择器仅在调用textfield时创建项目,即成为第一响应者,因此,我在textFieldDidBeginEditing中调用我的refreshPicker方法。不要忘记将textfield委托设置为self。=)对于那些遇到我问题的人,干杯

-(void) refreshPicker
{


    NSArray* mArray = [self.myTextField.text componentsSeparatedByString:@"."];
    NSNumber* str1 = [mArray objectAtIndex:0];
    int selectRow1 = [str1 intValue]-20;
    NSNumber* str2 = [mArray objectAtIndex:1];
    int selectRow = [str2 intValue];

    if (selectRow == 0) {
        int selectRow2 = 0;
        [self.pickerView selectRow:selectRow2 inComponent:1 animated:NO];
    }
    else if (selectRow == 5) {
        int selectRow2 = 1;
        [self.pickerView selectRow:selectRow2 inComponent:1 animated:NO];
    }

    [self.pickerView  selectRow:selectRow1 inComponent:0 animated:NO];

    [pickerView_ reloadAllComponents];


}