RAEditPhotoCell.m 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 (nonatomic,strong) IBOutlet UILabel *startLabel;
  13. @property (strong, nonatomic) IBOutlet UIImageView *photoView;
  14. @end
  15. @implementation RAEditPhotoCell
  16. - (void)awakeFromNib {
  17. [super awakeFromNib];
  18. // Initialization code
  19. self.model = nil;
  20. self.photoView.layer.borderWidth = 0.5f;
  21. self.photoView.layer.borderColor = [UIColor lightGrayColor].CGColor;
  22. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(photoViewTap:)];
  23. [self.photoView addGestureRecognizer:tap];
  24. }
  25. - (void)prepareForReuse {
  26. [super prepareForReuse];
  27. self.model = nil;
  28. self.delegate = nil;
  29. }
  30. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  31. [super setSelected:selected animated:animated];
  32. // Configure the view for the selected state
  33. }
  34. - (void)setModel:(RAEditPhotoModel *)model {
  35. if (_model) {
  36. _model.delegate = nil;
  37. }
  38. _model = model;
  39. _model.delegate = self;
  40. [self refresh];
  41. }
  42. - (void)photoViewTap:(UITapGestureRecognizer *)sender {
  43. if (self.delegate && [self.delegate respondsToSelector:@selector(photoCellWillOpenCameraOrShowPhoto:)]) {
  44. [self.delegate photoCellWillOpenCameraOrShowPhoto:self];
  45. }
  46. }
  47. #pragma mark - Model Delegate
  48. - (void)refresh {
  49. self.titleLabel.text = _model.title;
  50. self.photoView.image = _model.photo;
  51. self.startLabel.hidden = !_model.required;
  52. }
  53. - (void)unbind {
  54. _model = nil;
  55. [self refresh];
  56. }
  57. @end