Guest User

Untitled

a guest
Jan 21st, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. #import "PickerView.h"
  2.  
  3. @implementation PickerView
  4. @synthesize pickerView;
  5. @synthesize glassPicker, glassPickerOptions;
  6.  
  7. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
  8. {
  9. self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
  10. if (self) {
  11. // Custom initialization
  12. }
  13. return self;
  14. }
  15.  
  16. - (void)didReceiveMemoryWarning
  17. {
  18. // Releases the view if it doesn't have a superview.
  19. [super didReceiveMemoryWarning];
  20.  
  21. // Release any cached data, images, etc that aren't in use.
  22. }
  23.  
  24. #pragma mark - View lifecycle
  25.  
  26. - (void)viewDidLoad
  27. {
  28. [super viewDidLoad];
  29. // Do any additional setup after loading the view from its nib.
  30.  
  31. self.glassPickerOptions = [[NSArray alloc] initWithObjects:@"3mm",@"4mm",@"DG4+4",@"DG4+6",nil];
  32. [glassPicker setFrame:CGRectMake(0, 0, 320, 162)];
  33. [glassPicker selectRow:1 inComponent:0 animated:NO];
  34. }
  35.  
  36. - (void)viewDidUnload
  37. {
  38. [self setPickerView:nil];
  39. [self setGlassPicker:nil];
  40. [super viewDidUnload];
  41. // Release any retained subviews of the main view.
  42. // e.g. self.myOutlet = nil;
  43. }
  44.  
  45. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
  46. {
  47. // Return YES for supported orientations
  48. return (interfaceOrientation == UIInterfaceOrientationPortrait);
  49. }
  50.  
  51.  
  52. - (NSInteger) numberOfComponentsInPickerView:(UIPickerView *)pickerView
  53. {
  54. return 1;
  55. }
  56.  
  57. - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
  58. {
  59. NSInteger glassPickerOptionsCount = self.glassPickerOptions.count;
  60. return glassPickerOptionsCount;
  61. }
  62.  
  63. // Set the options
  64. - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
  65. {
  66. return (NSString*) [self.glassPickerOptions objectAtIndex:row];
  67. }
  68.  
  69. @end
Add Comment
Please, Sign In to add comment