I have a UIPicker which i'm developing through an array. In my array i am currently saving 10 values in it and number of rows of UIPicker counting array, then Picker shows 10 values in it .But my problem is, when i scroll the UIPicker, i want that after the 10th row is scrolled new rows should be automatically added with values filled in it. Actually i have added picker in an action sheet.This is my code through which i am loading data in picker.
- (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";
}
}
How to increment the row of picker dynamically when it is scrolled after the last array value.Thanks