Iphone 如何将包含分钟数的数组添加到UIPickerView?

Iphone 如何将包含分钟数的数组添加到UIPickerView?,iphone,uipickerview,Iphone,Uipickerview,我想向UIPickerView添加一些包含mint的数组,我想看到我的输出,如下所示 1分钟 2分钟 3分钟 4分钟 5分钟 。。。。。。。。 1140分钟 我怎么能,我有一个从1到1140的数组存储值,但想在UIPickerView上显示,在数字旁边写上“分钟”,使用这些函数 - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row for

我想向UIPickerView添加一些包含mint的数组,我想看到我的输出,如下所示

1分钟

2分钟

3分钟

4分钟

5分钟

。。。。。。。。

1140分钟

我怎么能,我有一个从1到1140的数组存储值,但想在UIPickerView上显示,在数字旁边写上“分钟”,使用这些函数

- (NSString *)pickerView:(UIPickerView *)pickerView 
             titleForRow:(NSInteger)row 
            forComponent:(NSInteger)component
{
    if(i == 1)
         return [NSString stringWithFormat:@"%d minute", row + 1];
    return [NSString stringWithFormat:@"%d minutes", row + 1];

}


-(NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component {

    return 120;
}
-(NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component {

    return 1140;
}


- (NSString *)pickerView:(UIPickerView *)pickerView 
             titleForRow:(NSInteger)row 
            forComponent:(NSInteger)component
{
  int n=row+1;
    if(row == 0)
         return [NSString stringWithFormat:@"%d minute", n];
    return [NSString stringWithFormat:@"%d minutes", n];

}

但它会重复多长时间?我只需要120分钟,现在不需要更多,直到用户决定向上滚动为止。好的,经过一点测试,我可以说这根本不起作用。即使是前3行也不行。因为UIPickerView不会一次请求所有行。它只请求当时显示的行。因此,假设您在方法中返回4。然后用户向下滚动,静态int i将变为7。而且没有可能再次选择4。在我的测试运行中,我看到选择器没有请求第0行、第1行、第2行、第3行。采摘者开始在底部1分钟,在中间他有3分钟。当我向下滚动4分钟,5分钟出现在1分钟@fluchtpunkt下面,对不起,我忘了那部分。我已经编辑了我的答案。当用户看到你的选择器时,他们会有一些想法:@“wtf?滚动到570需要很长时间。”@“1012分钟有多长?”