| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- //
- // FourImageCell.m
- // 千模
- //
- // Created by MUMEI on 2018/6/7.
- // Copyright © 2018年 MUMEI. All rights reserved.
- //
- #import "FourImageCell.h"
- @implementation FourImageCell
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
- {
- self = [super initWithStyle:style reuseIdentifier:reuseIdentifier ];
- if (self) {
- // 初始化子视图
- [self buildLabelOne];
- }
- return self;
- }
- - (void)awakeFromNib {
- [super awakeFromNib];
- [self buildLabelOne];
- // Initialization code
- }
- - (void)setNum:(int)num{
-
- if(num==3){
- self.image4.hidden = YES;
- }
- }
- - (void)setModel:(PrivateModel *)model{
- _model = model;
- self.detailLabel.text = model.intro;
- [self buildLabelOne];
- NSString *now = [Helper getCurrentTimes];
- NSString *lastDay = [Helper getLastTimes];
- NSArray * dateNow = [now componentsSeparatedByString:@" "];
- NSArray * nowYMD = [dateNow[0] componentsSeparatedByString:@"-"];
- NSString * nowY = nowYMD[0];
- NSString * nowM = nowYMD[1];
- NSString * nowD = nowYMD[2];
- NSArray * dateLast = [lastDay componentsSeparatedByString:@" "];
- NSArray * lastYMD = [dateLast[0] componentsSeparatedByString:@"-"];
- NSString * lastY = lastYMD[0];
- NSString * lastM = lastYMD[1];
- NSString * lastD = lastYMD[2];
-
- NSArray * date = [model.pdate componentsSeparatedByString:@" "];
- NSString * date2 = date[0];
- NSArray * YMD = [date2 componentsSeparatedByString:@"-"];
- NSString * Y = YMD[0];
- NSString * M = YMD[1];
- NSString * D = YMD[2];
-
- if ([Y isEqualToString:nowY]) {
- if ([M isEqualToString:nowM]) {
- if ([D isEqualToString:nowD]) {
- D = @"今天";
- self.Day.text = @"";
- self.Mounth.hidden = YES;
- self.noMonth = YES;
- }
- }
- }
- if ([Y isEqualToString:lastY]) {
- if ([M isEqualToString:lastM]) {
- if ([D isEqualToString:lastD]) {
- D = @"昨天";
- self.Day.text = D;
- self.Mounth.hidden = YES;
- self.noMonth = YES;
- }
- }
- }
- if (!self.noMonth) {
- if([M isEqualToString:@"01"]){
- M = @"1";
- }else if ([M isEqualToString:@"02"]){
- M = @"2";
- }else if ([M isEqualToString:@"03"]){
- M = @"3";
- }else if ([M isEqualToString:@"04"]){
- M = @"4";
- }else if ([M isEqualToString:@"05"]){
- M = @"5";
- }else if ([M isEqualToString:@"06"]){
- M = @"6";
- }else if ([M isEqualToString:@"07"]){
- M = @"7";
- }else if ([M isEqualToString:@"08"]){
- M = @"8";
- }else if ([M isEqualToString:@"09"]){
- M = @"9";
- }else if ([M isEqualToString:@"10"]){
- M = @"10";
- }else if ([M isEqualToString:@"11"]){
- M = @"11";
- }else if ([M isEqualToString:@"12"]){
- M = @"12";
- }
- self.Day.text = D;
- self.Mounth.text = [NSString stringWithFormat:@"%@月",M];
- }
- for (int i=0; i<model.iteminfo.count; i++) {
- NSString *url = [model.iteminfo[i] objectForKey:@"url"];
- if (i==0) {
- [self.image1 sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",imageURl,url]] placeholderImage:[UIImage imageNamed:@"jiazai"]];
- }else if (i==1){
- [self.image2 sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",imageURl,url]] placeholderImage:[UIImage imageNamed:@"jiazai"]];
- }else if (i==2){
- [self.image3 sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",imageURl,url]] placeholderImage:[UIImage imageNamed:@"jiazai"]];
- }else if (i==3){
- [self.image4 sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",imageURl,url]] placeholderImage:[UIImage imageNamed:@"jiazai"]];
- }
- }
- NSLog(@"date = %@",[Helper sharedAccount].date);
- UITapGestureRecognizer *Tap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(toImage1:)];;
- [self.image1 addGestureRecognizer:Tap1];
- self.image1.userInteractionEnabled = YES;
-
- UITapGestureRecognizer *Tap2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(toImage2:)];;
- [self.image2 addGestureRecognizer:Tap2];
- self.image2.userInteractionEnabled = YES;
-
- UITapGestureRecognizer *Tap3 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(toImage3:)];;
- [self.image3 addGestureRecognizer:Tap3];
- self.image3.userInteractionEnabled = YES;
-
- UITapGestureRecognizer *Tap4 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(toImage4:)];;
- [self.image4 addGestureRecognizer:Tap4];
- self.image4.userInteractionEnabled = YES;
- // if([[Helper sharedAccount].date isEqualToString:date2]){
- // self.Day.hidden = YES;
- // self.Mounth.hidden = YES;
- // }
- // [Helper sharedAccount].date = date2;
- if ([model.isditto isEqualToString:@"1"]) {
- self.Day.hidden = YES;
- self.Mounth.hidden = YES;
- }
- }
- - (void)toImage1:(UITapGestureRecognizer*)recognizer {
- [self.delegate clickImage:_model andNum:0];
- }
- - (void)toImage2:(UITapGestureRecognizer*)recognizer {
- [self.delegate clickImage:_model andNum:1];
- }
- - (void)toImage3:(UITapGestureRecognizer*)recognizer {
- [self.delegate clickImage:_model andNum:2];
- }
- - (void)toImage4:(UITapGestureRecognizer*)recognizer {
- [self.delegate clickImage:_model andNum:3];
- }
- #pragma mark - labelOne SizeToFitHeight
- - (void)buildLabelOne
- {
- self.detailLabel.text = _model.intro;
- _detailLabel.font = [UIFont systemFontOfSize:15];
- _detailLabel.numberOfLines = 0;
- CGFloat height = [UILabel getHeightByWidth:_detailLabel.frame.size.width title:_detailLabel.text font:_detailLabel.font];
- if (height>80) {
- height = 80;
- }
- _detailLabel.frame = CGRectMake(210, 15, 135, height);
- }
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
- // Configure the view for the selected state
- }
- @end
|