懒加载使用属性的声明方式,初始化方法以外需要使用self.调用
@property (nonatomic,strong)LDJDailyFreshnessView * freshnessView;-(LDJDailyFreshnessView *)freshnessView{ if (!_freshnessView) { _freshnessView = [[[NSBundle mainBundle]loadNibNamed:@"LDJDailyFreshnessView" owner:self options:nil]lastObject]; _freshnessView.frame = CGRectMake(0, -[DMDevceManager screenHeight], [DMDevceManager screenWidth], [DMDevceManager screenHeight]); LDJDailyFreshnessModel * model = dailyInfoArray[0]; _freshnessView.model = model; } return _freshnessView;}
传值给xib UIView的.m model时:重写setter方法,写在初始化方法里不行.
-(void)setModel:(LDJDailyFreshnessModel *)model{ _model = model; self.photoSchoolLabel.text = self.model.photo_kdg_name;}