// // RAEditPhotoCell.m // Apex And Drivers // // Created by Jack on 2018/6/4. // Copyright © 2018年 USAI. All rights reserved. // #import "RAEditPhotoCell.h" #import "RAEditPhotoModel.h" @interface RAEditPhotoCell () @property (strong, nonatomic) IBOutlet UILabel *titleLabel; @property (strong, nonatomic) IBOutlet UIImageView *photoView; @end @implementation RAEditPhotoCell - (void)awakeFromNib { [super awakeFromNib]; // Initialization code self.model = nil; self.photoView.layer.borderWidth = 0.5f; self.photoView.layer.borderColor = [UIColor lightGrayColor].CGColor; UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(photoViewTap:)]; [self.photoView addGestureRecognizer:tap]; } - (void)prepareForReuse { [super prepareForReuse]; self.model = nil; self.delegate = nil; } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } - (void)setModel:(RAEditPhotoModel *)model { if (_model) { _model.delegate = nil; } _model = model; _model.delegate = self; [self refresh]; } - (void)photoViewTap:(UITapGestureRecognizer *)sender { if (self.delegate && [self.delegate respondsToSelector:@selector(photoCellWillOpenCameraOrShowPhoto:)]) { [self.delegate photoCellWillOpenCameraOrShowPhoto:self]; } } #pragma mark - Model Delegate - (void)refresh { self.titleLabel.text = _model.title; self.photoView.image = _model.photo; } @end