Using UIPickerView


/ Published in: Objective C
Save to your folder(s)

1) Make sure the ViewController for the view implements the \< UIPickerViewDelegate, >


Copy this code and paste it in your HTML
  1. - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView {
  2. return 1;
  3. }
  4.  
  5. - (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component {
  6. return [foodTypes count];
  7. }
  8.  
  9. - (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
  10. return [foodTypes objectAtIndex:row];
  11. }
  12.  
  13. - (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
  14. //NSLog(@"Selected Color: %@. Index of selected color: %i", [foodTypes objectAtIndex:row], row);
  15. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.