// // RAPhotoItemCell.m // Apex And Drivers // // Created by Jack on 2018/10/30. // Copyright © 2018年 USAI. All rights reserved. // #import "RAPhotoItemCell.h" #import "RAPhotoModelDelegate.h" #import "RAPhotoItemModel.h" @interface RAPhotoItemCell () @property (nonatomic,strong) IBOutlet UIImageView *photoView; @end @implementation RAPhotoItemCell + (NSString *)reuseId { return @"RAPhotoItemCell"; } + (void)regist2CollectionView:(UICollectionView *)collectionView { if (!collectionView) { return; } [collectionView registerNib:[UINib nibWithNibName:@"RAPhotoItemCell" bundle:nil] forCellWithReuseIdentifier:[self reuseId]]; } #pragma mark - Super - (void)awakeFromNib { [super awakeFromNib]; // Initialization code self.photoView.layer.borderWidth = 0.5f; self.photoView.layer.borderColor = [UIColor lightGrayColor].CGColor; } - (void)prepareForReuse { [super prepareForReuse]; self.model = nil; } #pragma mark - Setter - (void)setModel:(RAPhotoItemModel *)model { _model.delegate = nil; _model = model; _model.delegate = self; // NSLog(@"Photo Item Cell SetModel: %p %p",self,model); [self refreshUI]; } #pragma mark - Model Delegate - (void)refreshUI { self.photoView.image = _model.photo; } - (void)unbind { // NSLog(@"Photo Item Cell Unbind: %p",self); _model = nil; [self refreshUI]; } #pragma mark - Action - (IBAction)photoBtnClick:(UIButton *)sender { if (self.clickBlk) { self.clickBlk(self.model); } } @end