我想在UIPickerView中添加一些包含mints的数组,我希望看到我的输出如下,
1分钟
2分钟
3分钟
4分钟
5分钟
........ ........
1140分钟
我怎么能,我有1到1140的数组存储值,但想在UIPickerView上显示,并在数字旁边写'分钟',
答案 0 :(得分:2)
使用这些功能
-(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];
}
答案 1 :(得分:0)
- (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;
}