Advertisement
Guest User

Untitled

a guest
Apr 16th, 2014
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. @interface NJATimeEntryViewController : UIViewController <UIPickerViewDelegate, UIPickerViewDataSource>
  2.  
  3. @property (nonatomic, strong) UIPickerView *customerPicker;
  4. @property (nonatomic, strong) NSArray *pickerTitles;
  5.  
  6. @end
  7.  
  8. - (void)viewDidLoad
  9. {
  10. [super viewDidLoad];
  11.  
  12. self.pickerTitles = @[@"ONE", @"TWO", @"THREE"];
  13.  
  14. self.customerPicker = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 200, 320, 200)];
  15. self.customerPicker.dataSource = self;
  16. self.customerPicker.delegate = self;
  17.  
  18. [self.view addSubview:self.customerPicker];
  19. }
  20.  
  21. -(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
  22. {
  23. return 1;
  24. }
  25.  
  26. -(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
  27. {
  28. return self.pickerTitles.count;
  29. }
  30.  
  31.  
  32. -(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
  33. {
  34. return [[self pickerTitles] objectAtIndex:row];
  35. }
  36.  
  37. - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
  38. {
  39. NSLog(@"Selected Row %d", row);
  40. }
  41.  
  42. self.view.backgroundColor=[UIColor yellowColor];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement