123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 |
- //
- // FaqCell.m
- // jiaPei
- //
- // Created by apple on 15/12/10.
- // Copyright © 2015年 JCZ. All rights reserved.
- //
- #import "FaqCell.h"
- @interface FaqCell()
- @property(nonatomic,strong)UIImageView* iv2;
- @property(nonatomic,strong)UILabel* textLbl2;
- @property(nonatomic,strong)UILabel* detailLbl2;
- @property(nonatomic,strong)UILabel* dateLbl;
- @property(nonatomic,strong)UILabel* dateLbl2;
- @end
- @implementation FaqCell
- - (void)awakeFromNib {
- [super awakeFromNib];
- // Initialization codenon
- }
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
- }
- +(FaqCell*)cellForTableView:(UITableView*)tableView
- {
- FaqCell* cell = [tableView dequeueReusableCellWithIdentifier:@"FaqCell"];
- if (!cell) {
- cell = [[FaqCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"FaqCell"];
- UILabel* label;
- label = [UILabel new];
- [cell addSubview:label];
- cell.textLbl2 = label;
- label = [UILabel new];
- [cell addSubview:label];
- cell.detailLbl2 = label;
- label = [UILabel new];
- [cell addSubview:label];
- cell.dateLbl = label;
- label = [UILabel new];
- [cell addSubview:label];
- cell.dateLbl2 = label;
- UIImageView* iv = [UIImageView new];
- [cell addSubview:iv];
- cell.iv2 = iv;
-
- [cell.imageView setContentMode:UIViewContentModeScaleAspectFit];
- [cell.iv2 setContentMode:UIViewContentModeScaleAspectFit];
-
- [cell.textLabel setTextColor:defGreen];
- [cell.textLabel setFont:[UIFont scaleSize:NormalFont]];
- [cell.textLbl2 setTextColor:RGB_COLOR(253, 115, 61)];
- [cell.textLbl2 setFont:[UIFont scaleSize:NormalFont]];
- [cell.detailTextLabel setTextColor:contentTextColor];
- [cell.detailTextLabel setFont:[UIFont scaleSize:14]];
- [cell.detailLbl2 setTextColor:contentTextColor];
- [cell.detailLbl2 setFont:[UIFont scaleSize:14]];
- [cell.dateLbl setTextColor:contentTextColor];
- [cell.dateLbl setFont:[UIFont scaleSize:14]];
- [cell.dateLbl2 setTextColor:contentTextColor];
- [cell.dateLbl2 setFont:[UIFont scaleSize:14]];
-
- cell.detailTextLabel.numberOfLines = 0;
- cell.detailLbl2.numberOfLines = 0;
- [cell.dateLbl setTextAlignment:NSTextAlignmentRight];
- [cell.dateLbl2 setTextAlignment:NSTextAlignmentRight];
- }
- return cell;
- }
- -(void)setModel:(NSDictionary *)model
- {
- _model = model;
- NSString* str;
- [self.imageView setImage:[UIImage imageNamed:@"faqImg0.png"]];
- [self.iv2 setImage:[UIImage imageNamed:@"faqImg1.png"]];
-
- NSString *nameString = model[@"userName"];
- if (nameString.length < 1) {
- nameString = @"匿名";
- }
- [self.textLabel setText:nameString];
-
- [self.dateLbl setText:model[@"crDate"]];
- if (model[@"answerDate"]) {
- [self.dateLbl2 setText:model[@"answerDate"]];
- }else{
- [self.dateLbl2 setText:@""];
- }
-
- [self.detailTextLabel setText:model[@"content"]];
- [self.textLbl2 setText:@"驾校回复"];
-
- str = model[@"answerContent"];
- if (!str) {
- str = @"等待驾校回复中...";
- }
- [self.detailLbl2 setText:str];
- }
- -(void)setSuggestModel:(NSDictionary *)suggestModel
- {
- _suggestModel = suggestModel;
-
- [self.imageView setImage:[UIImage imageNamed:@""]];
-
- NSString *path = defUser.userDict[@"photo"];
- if (path && ![path hasPrefix:@"http"]){
- path = [imgPreFix stringByAppendingString:path];
- }
- if (!path || path.length < 1) {
- path = @"";
- }
- [self.imageView sd_setImageWithURL:[NSURL URLWithString:path] placeholderImage:[UIImage imageNamed:@"faqImg0.png"]];
-
- [self.iv2 setImage:[UIImage imageNamed:@"faqImg2.png"]];
-
- [self.textLabel setText:@"其它建议"];
- [self.dateLbl setText:suggestModel[@"ANSWERTIME"]];
- [self.detailTextLabel setText:suggestModel[@"ANSWERCONTENT"]];
-
- [self.dateLbl2 setText:suggestModel[@"REPLYTIME"]];
-
- NSString *str = suggestModel[@"REPLYUSER"];
- if (!str || str.length < 1) {
- str = @"暂无回复";
- }
- [self.textLbl2 setText:str];
-
- str = suggestModel[@"REPLYCONTENT"];
- if (!str || str.length < 1) {
- str = @"等待回复中...";
- }
- [self.detailLbl2 setText:str];
- }
- -(void)layoutSubviews
- {
- [super layoutSubviews];
-
- CGFloat wid = kSize.width;
-
- CGFloat x,y,w,h,bd;
- bd = 10;
- x = bd*2;
- y = bd;
- w = h = 40;
- [self.imageView setFrame:CGRectMake(x, y, w, h)];
-
- x += w+bd;
- y = 0;
- w = wid - x;
- h = 35;
- [self.textLabel setFrame:CGRectMake(x, y, w, h)];
- [self.dateLbl setFrame:CGRectMake(x-bd, y, w, h)];
-
- y += h;
- w -= 2*bd;
- h = [self.detailTextLabel.text heightForWid:w Font:14];
- if (h < 25) {
- h = 25;
- }
- [self.detailTextLabel setFrame:CGRectMake(x, y, w, h)];
-
- y += h + 2*bd;
- x = bd*2;
- w = h = 40;
- [self.iv2 setFrame:CGRectMake(x, y, w, h)];
-
- x += w+bd;
- y -= bd;
- w = wid - x;
- h = 35;
- [self.textLbl2 setFrame:CGRectMake(x, y, w, h)];
- [self.dateLbl2 setFrame:CGRectMake(x-bd, y, w, h)];
- y += h;
- w -= 2*bd;
- h = [self.detailLbl2.text heightForWid:w Font:14];
- if (h < 25) {
- h = 25;
- }
- [self.detailLbl2 setFrame:CGRectMake(x, y, w, h)];
- }
- @end
|