RAEditPhotoCell.m 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. //
  2. // RAEditPhotoCell.m
  3. // Apex And Drivers
  4. //
  5. // Created by Jack on 2018/6/4.
  6. // Copyright © 2018年 USAI. All rights reserved.
  7. //
  8. #import "RAEditPhotoCell.h"
  9. #import "RAEditPhotoModel.h"
  10. @interface RAEditPhotoCell () <RAEditModelDelegate>
  11. @property (strong, nonatomic) IBOutlet UILabel *titleLabel;
  12. @property (strong, nonatomic) IBOutlet UIImageView *photoView;
  13. @end
  14. @implementation RAEditPhotoCell
  15. - (void)awakeFromNib {
  16. [super awakeFromNib];
  17. // Initialization code
  18. self.model = nil;
  19. self.photoView.layer.borderWidth = 0.5f;
  20. self.photoView.layer.borderColor = [UIColor lightGrayColor].CGColor;
  21. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(photoViewTap:)];
  22. [self.photoView addGestureRecognizer:tap];
  23. }
  24. - (void)prepareForReuse {
  25. [super prepareForReuse];
  26. self.model = nil;
  27. self.delegate = nil;
  28. }
  29. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  30. [super setSelected:selected animated:animated];
  31. // Configure the view for the selected state
  32. }
  33. - (void)setModel:(RAEditPhotoModel *)model {
  34. if (_model) {
  35. _model.delegate = nil;
  36. }
  37. _model = model;
  38. _model.delegate = self;
  39. [self refresh];
  40. }
  41. - (void)photoViewTap:(UITapGestureRecognizer *)sender {
  42. if (self.delegate && [self.delegate respondsToSelector:@selector(photoCellWillOpenCameraOrShowPhoto:)]) {
  43. [self.delegate photoCellWillOpenCameraOrShowPhoto:self];
  44. }
  45. }
  46. #pragma mark - Model Delegate
  47. - (void)refresh {
  48. self.titleLabel.text = _model.title;
  49. self.photoView.image = _model.photo;
  50. }
  51. @end