Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to solve uipickerview
    text
    copied!<p>I have a problem with my pickerview where by clicking on the textfield it shows an empty uipickerview. I have 3 textfield where by clicking on each textfield there will be different array for each one. Here's the code:</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; tbMode.inputView = pickerView; tbWalkDist.inputView = pickerView; tbRouteOpt.inputView = pickerView; } -(BOOL)textFieldShouldReturn:(UITextField *)textField { [textField resignFirstResponder]; return YES; } -(void)textFieldDidBeginEditing:(UITextField*)textField; { modeArray = [[NSMutableArray alloc] init]; if(textField.tag==1){ [modeArray addObject:@" A "]; [modeArray addObject:@" B "]; pickerView.hidden = NO; } else{ if(textField.tag==2){ [modeArray addObject:@" 300 "]; [modeArray addObject:@" 400 "]; [modeArray addObject:@" 500 "]; pickerView.hidden = NO; } else{ if(textField.tag==3){ [modeArray addObject:@" cheapest "]; [modeArray addObject:@" fastest "]; pickerView.hidden = NO; } else{ pickerView.hidden=YES; } } } } - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView; { return 1; } - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent: (NSInteger)component { tbMode.text = [modeArray objectAtIndex:row]; } - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component; { return [modeArray count]; } - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component; { return [modeArray objectAtIndex:row]; } </code></pre> <p>pls help! where did i got wrong? is it possible that this method <code>-(void)textFieldDidBeginEditing:(UITextField*)textField;</code> is not called? thanks</p> <p>edit* i miss out these 3 line of line which is for each textfield which use to call that method in <code>viewDidLoad</code></p> <pre><code>tbMode.delegate = self; tbWalkDist.delegate = self; tbRouteOpt.delegate = self; </code></pre> <p>But I'm still getting an empty picker view. how can i add these <code>NSMutableArray</code> into the the picker view *add in <code>[pickerView reloadAllComponents];</code> the picker will display the values :)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload