我有一个UIPicker,我正在通过一个数组开发。在我的数组中,我目前正在保存10个值和UIPicker计数数组的行数,然后Picker显示10个值。但我的问题是,当我滚动UIPicker时,我希望在第10行滚动后新行应自动添加填充的值。实际上我已经在一个动作表中添加了选择器。这是我的代码,通过它我可以在选择器中加载数据。
- (void)viewDidLoad
{
currentData = [[NSMutableArray alloc]initWithObjects:@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",nil];
[super viewDidLoad];
}
#pragma mark UIPickerViewDelegate Methods
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
return 1;
}
-(NSInteger)pickerView:(UIPickerView*)pickerView numberOfRowsInComponent:(NSInteger)component
{
int count;
if ([pickerType isEqualToString:@"picker"])
{
count = [currentData count];
}
return count;
}
-(NSString*)pickerView:(UIPickerView*)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
NSString *string;
if ([pickerType isEqualToString:@"picker"])
{
NSString *str = @"miles";
//string = [NSString stringWithFormat:@"%d",[currentData objectAtIndex:row],@"%@",str];
string = [NSString stringWithFormat:@"%@" @"%@",[currentData objectAtIndex:row],str];
NSLog(@"%@",string);
}
return string;
}
-(CGFloat)pickerView:(UIPickerView*)pickerView widthForComponent:(NSInteger)component
{
return 300;
}
-(void)pickerView:(UIPickerView*)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
select = YES;
if([barItems objectAtIndex:2]!=0)
{
if ([pickerType isEqualToString:@"picker"])
{
sessoTxt.text = [currentData objectAtIndex:row];
}
}
else{
sessoTxt.text = @"Select";
}
}
如何在最后一个数组值之后滚动选择器动态增量。谢谢
答案 0 :(得分:0)