UIPickerview filter list from a user previous textfield input

Posted by user1547180 on Stack Overflow See other posts from Stack Overflow or by user1547180
Published on 2012-11-27T04:51:17Z Indexed on 2012/11/27 5:04 UTC
Read the original article Hit count: 216

Filed under:
|
int variabla;


- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {

return 1;
}






- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {


if (variabla == 1)
    return list4.count;

else if(variabla == 2)
    return list3.count;

if (variabla == 3)
    return list1.count;


if (variabla == 4)
    return list2.count;



return YES;

[pickerView reloadAllComponents];
}










- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
if (variabla == 1) {
    subjectField.text = [list4 objectAtIndex:row];
}
else if  (variabla == 2) {
    gradeField.text = [list3 objectAtIndex:row];
}
else if (variabla == 3) {
    mathField.text = [list1 objectAtIndex:[pickerView selectedRowInComponent:0]];
    selectedRow = [pickerView selectedRowInComponent:0];
    coreTView.text = [mathMeaning objectAtIndex:selectedRow];
}
if (variabla == 4) {
    elaField.text = [list2 objectAtIndex:[pickerView selectedRowInComponent:0]];
    selectedRow = [pickerView selectedRowInComponent:0];
    coreTView.text = [elaMeaning objectAtIndex:selectedRow];
}



[pickerView reloadAllComponents];
NSLog(@"row selected is %d", selectedRow);

}







- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component  {

if (variabla == 1)
    return [list4 objectAtIndex:row];



if (variabla == 2)
    return [list3 objectAtIndex:row];

if (variabla == 3)
    return [list1 objectAtIndex:row];

if (variabla == 4)
    return [list2 objectAtIndex:row];

return NO;

[pickerView reloadAllComponents];
}

Hey I would like to know or pointed in the right direction on how to load a UIPickerView based on the user input from a previous uitextfield so if they type in the previous textfield apple I would like red, green, blue to show in the UIPickerView or if they type orange I would like to see orange, yellow grape thanks for the help in advance.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about ios