我要添加一些陣列含有薄荷糖到UIPickerView,我想看我的輸出像下面,如何將包含分鐘的數組添加到UIPickerView?
1分鐘
2分鐘
3分鐘
4分鐘
5分鐘
........ ........
1140分鐘
如何I,I有一個數組存儲的值從1到1140,但希望與 '分鐘' 寫入數字旁邊顯示上UIPickerView,
我要添加一些陣列含有薄荷糖到UIPickerView,我想看我的輸出像下面,如何將包含分鐘的數組添加到UIPickerView?
1分鐘
2分鐘
3分鐘
4分鐘
5分鐘
........ ........
1140分鐘
如何I,I有一個數組存儲的值從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;
}
但是它會重複多少次?我只需要120分鐘,而不是現在多於 – 2011-02-09 07:12:24
,直到用戶決定向上滾動爲止。 ,經過一個小小的測試後,我可以告訴這根本行不通,即使是前3行也是如此。 – 2011-02-09 07:13:57
使用這些功能
-(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];
}
用戶在看到您的選取器時會有一些想法:@「wtf? 「;」1012分鐘多久?「 – 2011-02-09 07:17:39