2009-11-24 53 views

回答

2

這是可能的。對於任何需要它的人, 嘗試this

1

我不認爲這是可能的。我聽說過許多人重複列表值,並將用戶從中間的某個地方啓動。

0

它確實有效,只是看內存。告訴沒有顯示的項目不存儲,因此可以使列表巨大。如果擔心,請與分析人員覈對。 將行數設置爲大數就很容易,並且使其以高數值開始,用戶很少有機會長時間滾動滾輪 - 即使如此,更糟糕的是,將會發生的是他們會觸底。

(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component { 
    // Near-infinite number of rows. use NSIntegerMax, if memory problem, use less say 2000 
    return 2000; 
} 

(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { 
    // Row n is same as row (n modulo numberItems). 
    return [NSString stringWithFormat:@"%d", row % numberItems]; // or your strings (this is for double. numberItems is your list size. 
} 

(void)viewDidLoad { 
    [super viewDidLoad]; 

    self.pickerView = [[[UIPickerView alloc] initWithFrame:CGRectZero] autorelease]; 
    // ...set pickerView properties... Look at Apple's UICatalog sample code for a good example. 
    // Set current row to a large value (adjusted to current value if needed). 
    [pickerView selectRow:3+1000 inComponent:0 animated:NO]; //pick about half the max you made earlier or about 100000 if using NSIntegerMax 
    [self.view addSubview:pickerView]; 
} 

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { 
    NSInteger actualRow = row % numberItems; //nb numberItems is your list size 
    // ... 
} 

喬恩

相關問題