-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathYLExampleImagesCell.m
64 lines (49 loc) · 2.28 KB
/
YLExampleImagesCell.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//
// YLExampleImagesCell.m
// YLTableViewExample
//
// Created by Mason Glidden on 6/2/15.
// Copyright (c) 2015 Yelp. All rights reserved.
//
#import "YLExampleImagesCell.h"
#import "YLExampleImagesCellModel.h"
#import "YLExampleImagesViewController.h"
#import <YLTableView/YLTableViewChildViewControllerCell.h>
@interface YLExampleImagesCell () <YLTableViewChildViewControllerCell>
@property (strong, nonatomic) YLExampleImagesViewController *imagesViewController;
@end
@implementation YLExampleImagesCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
_imagesViewController = [[YLExampleImagesViewController alloc] init];
_imagesViewController.view.translatesAutoresizingMaskIntoConstraints = NO;
[self.contentView addSubview:_imagesViewController.view];
[self _installConstraints];
}
return self;
}
#pragma mark Layout
- (void)_installConstraints {
// Make sure we display the controller's view
NSDictionary *views = @{ @"view": self.imagesViewController.view };
[self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[view]|" options:0 metrics:nil views:views]];
[self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[view]|" options:0 metrics:nil views:views]];
}
#pragma mark YLTableViewCell protocol
- (void)setModel:(id)model {
NSAssert([model isKindOfClass:[YLExampleImagesCellModel class]], @"Must use %@ with %@", NSStringFromClass([YLExampleImagesCellModel class]), NSStringFromClass([self class]));
// Pass the images through to the controller
YLExampleImagesCellModel *imagesModel = (YLExampleImagesCellModel *)model;
self.imagesViewController.imageOne = imagesModel.imageOne;
self.imagesViewController.imageTwo = imagesModel.imageTwo;
self.imagesViewController.imageThree = imagesModel.imageThree;
}
+ (CGFloat)estimatedRowHeight {
return 44.0;
}
#pragma mark YLTableViewChildViewControllerCell
- (YLExampleImagesViewController *)childViewController {
// By returning a child view controller here, it'll be added as a child of YLExampleViewController and recieve view events + access to the navigation controller.
return self.imagesViewController;
}
@end