Today's Menu  Portugal
journal and plan nutrition
Y4NutritionCollectionViewCell.m
Go to the documentation of this file.
1 //
2 // Y4NutritionCollectionViewCell.m
3 // TodaysMenu
4 //
5 // Created by Don Zeek on 4/19/16.
6 // Copyright © 2016 net.dzeek.y2015.ios.portfolio. All rights reserved.
7 //
8 
10 
12 @end
13 
14 @implementation Y4NutritionCollectionViewCell
15 - (id)initWithFrame:(CGRect)frame {
16 
17  self = [super initWithFrame:frame];
18 
19  if (self) {
20 
21 
22  // Initialization code
23  NSArray *arrayOfViews = [[NSBundle mainBundle] loadNibNamed:@"Y4NutritionItemView" owner:self options:nil];
24 
25  if ([arrayOfViews count] < 1) {
26  return nil;
27  }
28 
29  if (![[arrayOfViews objectAtIndex:0] isKindOfClass:[UICollectionViewCell class]]) {
30  return nil;
31  }
32  }
33 
34  return self;
35 
36 }
37 // Lazy loading of the imageView
38 - (UIImageView *) imageView
39 {
40  // controls image size
41  CGRect imageFrame = CGRectMake(0.0, 0.0, 180.0, 184.0);
42  if (!_imageView) {
43  _imageView = [[UIImageView alloc] initWithFrame:imageFrame];
44  _imageView.tag = 201;
45  [self.contentView addSubview:_imageView];
46  }
47  // NSLog(@"Y4NutritionCollectionViewCell.imageView: tag: %ld", (long)[_imageView tag]);
48  return _imageView;
49 }
50 
51 // Lazy loading of the textLabel
52 - (UILabel *) textLabel
53 {
54  CGRect textFrame = CGRectMake(0.0, 124.0, 120.0, 40.0);
55  if (!_textLabel) {
56  _textLabel = [[UILabel alloc] initWithFrame:textFrame];
57  _textLabel.backgroundColor = [UIColor colorWithRed:0.3f green:1.0f blue:0.7f alpha:1.0f];
58  _textLabel.font = [UIFont fontWithName:@"Verdana" size:10.0f];
59  _textLabel.tag = 202;
60 
61  [self.contentView addSubview:_textLabel];
62  }
63  // NSLog(@"Y4NutritionCollectionViewCell.textLabel: tag: %ld", (long)[_textLabel tag]);
64  return _textLabel;
65 }
66 
67 //- (void)setSelected:(BOOL)selected {
68 // [super setSelected:selected];
69 //
70 // if (selected) {
71 // [self animateSelection];
72 // } else {
73 // [self animateDeselection];
74 // }
75 //}
76 
77 
78 // Here we remove all the custom stuff that we added to our subclassed cell
80 {
81  [super prepareForReuse];
82 
83  [self.imageView removeFromSuperview];
84  [self.textLabel removeFromSuperview];
85 // [self.textLabel setText:@"Prepare4Reuse"];
86 // self.textLabel.textColor = [UIColor colorWithRed:0.05 green:0.3 blue:0.1 alpha:1.0];
87 
88  self.imageView = nil;
89  self.textLabel = nil;
90 }
91 
92 @end
UIImageView * imageView