Today's Menu  Portugal
journal and plan nutrition
Y4NutritionCollectSelectViewCell.m
Go to the documentation of this file.
1 //
2 // Y4NutritionCollectiSelectViewCell.m
3 // TodaysMenu
4 //
5 // Created by Don Zeek on 8/5/16.
6 // Copyright © 2016 net.dzeek.y2015.ios.portfolio. All rights reserved.
7 //
8 
10 
12 @end
13 
14 
16 
17 - (id)initWithFrame:(CGRect)frame {
18 
19  self = [super initWithFrame:frame];
20  // NSLog(@"NutritionSelectCollectCell.initWithFrame: height: %f", frame.size.height);
21 
22  if (self) {
23 
24 
25  // Initialization code
26  NSArray *arrayOfViews = [[NSBundle mainBundle] loadNibNamed:@"Y4NutritionSelectedItemViewCell" owner:self options:nil];
27 
28  if ([arrayOfViews count] < 1) {
29  return nil;
30  }
31 
32  if (![[arrayOfViews objectAtIndex:0] isKindOfClass:[UICollectionViewCell class]]) {
33  return nil;
34  }
35  }
36 
37  return self;
38 
39 }
40 // Lazy loading of the imageView
41 - (UIImageView *) imageView
42 {
43  CGRect imageFrame = CGRectMake(0.0, 0.0, 140.0, 148.0);
44  if (!_imageView) {
45  _imageView = [[UIImageView alloc] initWithFrame:imageFrame];
46  [self.contentView addSubview:_imageView];
47  }
48  return _imageView;
49 }
50 
51 // Lazy loading of the textLabel
52 - (UILabel *) textLabel
53 {
54  CGRect textFrame = CGRectMake(0.0, 148.0, 140.0, 40.0);
55  if (!_textLabel) {
56  _textLabel = [[UILabel alloc] initWithFrame:textFrame];
57  _textLabel.backgroundColor = [UIColor colorWithRed:0.6f green:1.0f blue:0.3f alpha:1.0f];
58  /*
59  _textLabel.textAlignment = NSTextAlignmentCenter;
60  _textLabel.textColor = [UIColor colorWithRed:0.05 green:0.3 blue:0.1 alpha:1.0];
61  [_textLabel setLineBreakMode:NSLineBreakByWordWrapping];
62  */
63  _textLabel.tag = 202;
64  [self.contentView addSubview:_textLabel];
65  }
66 
67 
68 // NSString *string = @"bla";
69 //
70 
71 
72 
73  // NSLog(@"NutrCollViewCell.textLabel: tag: %ld", [_textLabel tag]);
74  return _textLabel;
75 }
76 
77 // Here we remove all the custom stuff that we added to our subclassed cell
79 {
80  [super prepareForReuse];
81 
82  [self.imageView removeFromSuperview];
83  [self.textLabel removeFromSuperview];
84  // [self.textLabel setText:@"Prepare4Reuse"];
85  // self.textLabel.textColor = [UIColor colorWithRed:0.05 green:0.3 blue:0.1 alpha:1.0];
86 
87  self.imageView = nil;
88  self.textLabel = nil;
89 }
90 
91 /*
92 // Only override drawRect: if you perform custom drawing.
93 // An empty implementation adversely affects performance during animation.
94 - (void)drawRect:(CGRect)rect {
95  // Drawing code
96 }
97 */
98 
99 @end
UIImageView * imageView