// // TDInterLeterDetailVC.m // smartRhino // // Created by taidi on 2019/12/26. // Copyright © 2019 tederen. All rights reserved. // #import "TDInterLeterDetailVC.h" #import "NoteBookDetailCell.h" #import "CreateInterLeterVC.h" #import "MailListDetailVC.h" #import "NoticeUnreadVC.h" #import "MoveViewController.h" #import "NSDate+Extension.h" #import "CreateInterLeterVC.h" #import "NoteBookShareVC.h" #import "MyTDGroupViewController.h" #import "MyTDTopicCreateVC.h" #import "MoveViewController.h" @interface TDInterLeterDetailVC () @property (weak, nonatomic) IBOutlet UITableView *tableView; @property (strong,nonatomic) NSMutableArray * interLetterArray; @property (nonatomic,strong) NSMutableArray *commentArray; @property (nonatomic,assign) BOOL isFresh; @property (nonatomic,assign) NSUInteger currentPage; @property (nonatomic,assign) NSUInteger totalRecord; @property (weak, nonatomic) IBOutlet UIButton *commentButton; //@property (weak, nonatomic) IBOutlet UILabel *commentNumberLabel; @property (weak, nonatomic) IBOutlet UIButton *zanButton; @property (weak, nonatomic) IBOutlet UILabel *zanNumberLabel; @property (weak, nonatomic) IBOutlet UIButton *collectButton; @property (weak, nonatomic) IBOutlet UILabel *collectNumberLabel; @property (weak, nonatomic) IBOutlet UIButton *shareButton; @property (weak, nonatomic) IBOutlet UILabel *shareNumberLabel; @property (weak, nonatomic) IBOutlet UIImageView *zanImageView; @property (weak, nonatomic) IBOutlet UIImageView *collectImageView; @property (weak, nonatomic) IBOutlet UIImageView *shareImageView; @property (strong,nonatomic) InterLeterDetailSubModel * currentDetailModel; @property (strong,nonatomic) InterLeterDetailModel * detailModel; @property (strong, nonatomic) NoteBookShareVC *noteBookShareVC; @property (copy, nonatomic) NSString *replayTitle; @property (nonatomic,assign) BOOL labelShow; @end @implementation TDInterLeterDetailVC - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [self getData]; } +(TDInterLeterDetailVC *)initTDInterLeterDetailVC{ TDInterLeterDetailVC *controller = [StoryboardManager.shared.interLeterHome instantiateViewControllerWithIdentifier:@"TDInterLeterDetailVC"]; return controller; } - (void)viewDidLoad { [super viewDidLoad]; self.fd_prefersNavigationBarHidden = YES; self.view.backgroundColor = RGB(255, 255, 255); if (@available(iOS 11.0, *)) { self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; } else { self.automaticallyAdjustsScrollViewInsets = NO; } WS(weakSelf); [self.collectButton setAction:^{ [weakSelf gotoCollectHander]; }]; [self.shareButton setAction:^{ [weakSelf shareHander]; }]; [self.zanButton setAction:^{ [weakSelf gotoZanHander]; }]; [self.commentButton setAction:^{ [weakSelf commentHander]; }]; } - (void)getData{ switch (self.detailType) { case InterLeterDetialType_Sign: break; case InterLeterDetialType_NoSign: break; default: break; } SHOWLOADING; WS(weakSelf); [self.interLetterArray removeAllObjects]; [[HttpManager sharedHttpManager] GETUrl:[NSString stringWithFormat:@"%@%ld",Host(API_InterLetterDetail),(long)self.interLeterID] parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) { weakSelf.detailModel = [[InterLeterDetailModel alloc]initWithDictionary:responseObject error:nil]; REMOVESHOW NSLog(@"%@",responseObject); [weakSelf.interLetterArray addObjectsFromArray:weakSelf.detailModel.Items]; InterLeterDetailSubModel *mymodel = weakSelf.detailModel.Items.firstObject; weakSelf.currentDetailModel = mymodel; if(mymodel.IsCollect){ weakSelf.collectImageView.image = IMG(@"icon_collect_off"); }else{ weakSelf.collectImageView.image = IMG(@"收藏五角星"); } if (mymodel.IsPraise) { weakSelf.zanImageView.image = IMG(@"zan_yes"); }else{ weakSelf.zanImageView.image = IMG(@"zan_no"); } dispatch_async(dispatch_get_main_queue(), ^{ weakSelf.collectButton.selected = mymodel.IsCollect; weakSelf.zanButton.selected = mymodel.IsPraise; weakSelf.shareButton.selected = YES; weakSelf.zanNumberLabel.text = [NSString stringWithFormat:@"%ld",(long)mymodel.PraiseCount]; weakSelf.zanNumberLabel.textColor = !mymodel.IsPraise ? UIColorHex(#999999) : UIColorHex(#0F8AE3); weakSelf.collectNumberLabel.text = [NSString stringWithFormat:@"%ld",(long)mymodel.CollectCount]; weakSelf.collectNumberLabel.textColor = !mymodel.IsCollect ? UIColorHex(#999999) : UIColorHex(#0F8AE3); weakSelf.shareNumberLabel.text = [NSString stringWithFormat:@"%ld",(long)mymodel.RetransmissionCount]; weakSelf.zanNumberLabel.hidden = mymodel.PraiseCount == 0 ? YES : NO; weakSelf.collectNumberLabel.hidden = mymodel.CollectCount == 0 ? YES : NO; weakSelf.shareNumberLabel.hidden = mymodel.RetransmissionCount == 0 ? YES : NO; weakSelf.shareNumberLabel.textColor = UIColorHex(#0F8AE3); [weakSelf.tableView reloadData]; }); } failure:^(NSError * _Nonnull error) { SHOWERROR([ZYCTool handerResultData:error]); }]; [self.view addSubview:self.noteBookShareVC.view]; } - (NSMutableArray *)interLetterArray{ if (!_interLetterArray) { _interLetterArray = [NSMutableArray new]; } return _interLetterArray; } - (NSMutableArray *)commentArray{ if (!_commentArray) { _commentArray = [NSMutableArray new]; } return _commentArray; } - (void)getComment{ } #pragma mark - tableview 代理 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return self.interLetterArray.count; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ InterLeterDetailSubModel *model = self.interLetterArray[section]; switch (self.detailType) { case InterLeterDetialType_Sign:{ return model.Data.count + 1; }break; case InterLeterDetialType_NoSign:{ return model.Data.count + 1; }break; case InterLeterDetialType_Replay:{ switch (section) { case 0:{ // 最后一次回复 return model.Data.count + 1; }break; default:{// 往次回复 return model.Data.count + 2; }break; } }break; default: { return model.Data.count + 1; }break; } } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ WS(weakSelf); InterLeterDetailSubModel * model = self.interLetterArray[indexPath.section]; switch (self.detailType) { case InterLeterDetialType_Replay :{ switch (indexPath.section) { case 0:{ // 最后一次回复 switch (indexPath.row) { case 0:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell6:tableView indexPath:indexPath]; cell.cellArticleTitleLabel.text = model.Title; self.replayTitle = model.Title; if(model.AddresseeUsers.count == 0){ cell.cellArticleAuthor2Label.attributedText = [[NSAttributedString alloc] initWithString:@"收件人:--"]; }else{ NSMutableArray * userArray = [[NSMutableArray alloc] init]; for (InterLeterAddresseeUsers * userModel in model.AddresseeUsers) { [userArray addObject:userModel.Name]; } NSString * NoticeAddresseeNames = [NSString stringWithFormat:@"收件人: %@",[userArray componentsJoinedByString:@"、"]]; [cell layoutIfNeeded]; [self setCellLabel:cell.cellArticleAuthor2Label withText:NoticeAddresseeNames indexPath:indexPath isShow:self.labelShow]; UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithActionBlock:^(id _Nonnull sender) { weakSelf.labelShow = !weakSelf.labelShow; [weakSelf.tableView reloadRowAtIndexPath:indexPath withRowAnimation:UITableViewRowAnimationAutomatic]; }]; [cell.cellArticleAuthor2Label addGestureRecognizer:tap]; cell.cellArticleAuthor2Label.userInteractionEnabled = YES; } cell.cellArticleAuthorLabel.text = [NSString stringWithFormat:@"发件人:%@",model.UserName]; cell.cellArticleTimeLabel.numberOfLines = 1; cell.cellArticleTimeLabel.text = [NSDate getCHtimeWihtDate:model.CreatedDate]; cell.cellArticleReadNumberLabel.text = [NSString stringWithFormat:@"%ld",(long)model.ReadCount]; cell.cellArticleAllReadNumberLabel.text = [NSString stringWithFormat:@"/%ld",(long)model.AllCount]; [cell.checkReadButton setAction:^{ [weakSelf checkRead]; }]; [cell.checkPeopleButton setAction:^{ [weakSelf checkReadUserId:model.UserId]; }]; cell.cellArticleEditorButton.hidden = YES; cell.cellArticleDeleteButton.hidden = YES; return cell; }break; default:{ InterLeterDetailDataModel *dataModel = model.Data[indexPath.row - 1]; switch (dataModel.Type) { case CollectDataType_Text:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell1:tableView indexPath:indexPath]; cell.cell0ImgTitleLab.text = dataModel.Text; return cell; }break; case CollectDataType_IMG:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell0:tableView indexPath:indexPath]; [cell.cell0ImgView sd_setImageWithURL:[NSURL URLWithString:dataModel.File] placeholderImage:IMG(@"img_placeHolder")completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { [self.tableView reloadRowAtIndexPath:indexPath withRowAnimation:UITableViewRowAnimationAutomatic]; }]; return cell; }break; case CollectDataType_File:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell2:tableView indexPath:indexPath]; NSString * imageName = [ZYCTool getFileNameImage:dataModel.File]; if (imageName.length > 0) { cell.cell1IconImageView.image = IMG(imageName); }else{ [cell.cell1IconImageView sd_setImageWithURL:[NSURL URLWithString:dataModel.File] placeholderImage:IMG(@"icon_weizhiwenjian")]; } cell.cell1TitleLabel.text = dataModel.FileName; cell.cell1Authorlabel.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@",dataModel.Author] KeyString:dataModel.Author]; return cell; }break; case CollectDataType_Article:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell2:tableView indexPath:indexPath]; cell.cell1IconImageView.image = IMG(@"文章"); cell.cell1TitleLabel.text = dataModel.FileName; cell.cell1Authorlabel.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的文章",dataModel.Author] KeyString:dataModel.Author]; return cell; }break; case CollectDataType_Notice:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell2:tableView indexPath:indexPath]; cell.cell1IconImageView.image = IMG(@"通知图标"); cell.cell1TitleLabel.text = dataModel.Title; cell.cell1Authorlabel.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的通知",dataModel.Author] KeyString:dataModel.Author]; return cell; }break; case CollectDataType_Topic:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell2:tableView indexPath:indexPath]; cell.cell1IconImageView.image = IMG(@"话题"); cell.cell1TitleLabel.text = dataModel.Title; cell.cell1Authorlabel.text = dataModel.Author; return cell; }break; case CollectDataType_Note:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell2:tableView indexPath:indexPath]; cell.cell1IconImageView.image = IMG(@"noteBook_icon"); cell.cell1TitleLabel.text = dataModel.Title; cell.cell1Authorlabel.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的笔记",dataModel.Author] KeyString:dataModel.Author]; return cell; }break; case CollectDataType_Collect:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell2:tableView indexPath:indexPath]; cell.cell1IconImageView.image = IMG(@"收藏"); cell.cell1TitleLabel.text = dataModel.Title; cell.cell1Authorlabel.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的收藏",dataModel.Author] KeyString:dataModel.Author]; return cell; }break; case CollectDataType_NoteFile:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell2:tableView indexPath:indexPath]; cell.cell1IconImageView.image = IMG(@"find_1"); cell.cell1TitleLabel.text = dataModel.Title; cell.cell1Authorlabel.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的笔记文件夹",dataModel.Author] KeyString:dataModel.Author]; return cell; }break; case CollectDataType_CollectFile:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell2:tableView indexPath:indexPath]; cell.cell1IconImageView.image = IMG(@"find_1"); cell.cell1TitleLabel.text = dataModel.Title; cell.cell1Authorlabel.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的收藏文件夹",dataModel.Author] KeyString:dataModel.Author]; return cell; }break; case CollectDataType_InterMail:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell2:tableView indexPath:indexPath]; cell.cell1IconImageView.image = IMG(@"站内信图"); cell.cell1TitleLabel.text = dataModel.Title; cell.cell1Authorlabel.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的收藏",dataModel.Author] KeyString:dataModel.Author]; return cell; }break; case CollectDataType_Group:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell2:tableView indexPath:indexPath]; cell.cell1IconImageView.image = IMG(@"笔记小组"); cell.cell1TitleLabel.text = dataModel.Title; cell.cell1Authorlabel.text = dataModel.Author; return cell; }break; case CollectDataType_Approval:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell2:tableView indexPath:indexPath]; cell.cell1IconImageView.image = IMG(@"审批"); cell.cell1TitleLabel.text = dataModel.Title; cell.cell1Authorlabel.text = dataModel.Author; return cell; }break; default:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell1:tableView indexPath:indexPath]; return cell; }break; } }break; } }break; default:{// 往次回复 switch (indexPath.row) { case 0:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell8:tableView indexPath:indexPath]; return cell; } case 1:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell6:tableView indexPath:indexPath]; cell.cellArticleTitleLabel.text = model.Title; if(model.AddresseeUsers.count == 0){ cell.cellArticleAuthorLabel.text = @"--"; }else{ NSMutableArray * userArray = [[NSMutableArray alloc] init]; for (InterLeterAddresseeUsers * userModel in model.AddresseeUsers) { [userArray addObject:userModel.Name]; } NSString * NoticeAddresseeNames = [NSString stringWithFormat:@"收件人: %@",[userArray componentsJoinedByString:@"、"]]; [cell layoutIfNeeded]; [self setCellLabel:cell.cellArticleAuthor2Label withText:NoticeAddresseeNames indexPath:indexPath isShow:self.labelShow]; UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithActionBlock:^(id _Nonnull sender) { weakSelf.labelShow = !weakSelf.labelShow; [weakSelf.tableView reloadRowAtIndexPath:indexPath withRowAnimation:UITableViewRowAnimationAutomatic]; }]; [cell.cellArticleAuthor2Label addGestureRecognizer:tap]; cell.cellArticleAuthor2Label.userInteractionEnabled = YES; } cell.cellArticleAuthorLabel.textColor = UIColorHex(999999); cell.cellArticleReadNumberLabel.textColor = UIColorHex(999999); cell.cellArticleAuthorLabel.text = model.UserName; cell.cellArticleTimeLabel.numberOfLines = 1; cell.cellArticleTimeLabel.text = [NSDate getCHtimeWihtDate:model.CreatedDate]; cell.cellArticleReadNumberLabel.text = [NSString stringWithFormat:@"%ld",(long)model.ReadCount]; cell.cellArticleAllReadNumberLabel.text = [NSString stringWithFormat:@"/%ld",(long)model.AllCount]; [cell.cellArticleDeleteButton setTitle:@"撤回" forState:UIControlStateNormal]; WS(weakSelf); [cell.checkReadButton setAction:^{ [weakSelf checkRead]; }]; [cell.checkPeopleButton setAction:^{ [weakSelf checkReadUserId:model.UserId]; }]; if (model.IsAdmin) { cell.cellArticleEditorButton.hidden = NO; cell.cellArticleDeleteButton.hidden = NO; }else{ cell.cellArticleEditorButton.hidden = YES; cell.cellArticleDeleteButton.hidden = YES; } [cell.cellArticleDeleteButton setAction:^{ [weakSelf deleteButtonHander:model.Id]; }]; [cell.cellArticleEditorButton setAction:^{ [weakSelf editorButtonHander:model.Id]; }]; return cell; }break; default:{ InterLeterDetailDataModel *dataModel = model.Data[indexPath.row-2]; switch (dataModel.Type) { case CollectDataType_Text:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell1:tableView indexPath:indexPath]; cell.cell0ImgTitleLab.text = dataModel.Text; return cell; }break; case CollectDataType_IMG:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell0:tableView indexPath:indexPath]; [cell.cell0ImgView sd_setImageWithURL:[NSURL URLWithString:dataModel.File] placeholderImage:IMG(@"img_placeHolder")completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { [self.tableView reloadRowAtIndexPath:indexPath withRowAnimation:UITableViewRowAnimationAutomatic]; }]; return cell; }break; case CollectDataType_File:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell2:tableView indexPath:indexPath]; NSString * imageName = [ZYCTool getFileNameImage:dataModel.File]; if (imageName.length > 0) { cell.cell1IconImageView.image = IMG(imageName); }else{ [cell.cell1IconImageView sd_setImageWithURL:[NSURL URLWithString:dataModel.File] placeholderImage:IMG(@"icon_weizhiwenjian")]; } cell.cell1TitleLabel.text = dataModel.FileName; cell.cell1Authorlabel.text = dataModel.Author; return cell; }break; case CollectDataType_Article:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell2:tableView indexPath:indexPath]; switch (dataModel.ArticleImgUrl.count) { case 0:{ cell.cell1IconImageView.image = IMG(@"icon_myPaper"); }break; default:{ [cell.cell1IconImageView sd_setImageWithURL:[NSURL URLWithString:dataModel.ArticleImgUrl.firstObject] placeholderImage:IMG(@"img_placeHolder")completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {}]; }break; } [cell.cell1IconImageView sd_setImageWithURL:[NSURL URLWithString:dataModel.File] placeholderImage:IMG(@"img_placeHolder")completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { }]; cell.cell1TitleLabel.text = dataModel.FileName; cell.cell1Authorlabel.text = dataModel.Author; return cell; }break; case CollectDataType_Notice:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell2:tableView indexPath:indexPath]; cell.cell1IconImageView.image = IMG(@"通知图标"); cell.cell1TitleLabel.text = dataModel.Title; cell.cell1Authorlabel.text = dataModel.Author; return cell; }break; case CollectDataType_Topic:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell2:tableView indexPath:indexPath]; cell.cell1IconImageView.image = IMG(@"话题"); cell.cell1TitleLabel.text = dataModel.Title; cell.cell1Authorlabel.text = dataModel.Author; return cell; }break; case CollectDataType_Note:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell2:tableView indexPath:indexPath]; cell.cell1IconImageView.image = IMG(@"noteBook_icon"); cell.cell1TitleLabel.text = dataModel.Title; cell.cell1Authorlabel.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的笔记",dataModel.Author] KeyString:dataModel.Author]; return cell; }break; case CollectDataType_Collect:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell2:tableView indexPath:indexPath]; cell.cell1IconImageView.image = IMG(@"收藏"); cell.cell1TitleLabel.text = dataModel.Title; cell.cell1Authorlabel.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的收藏",dataModel.Author] KeyString:dataModel.Author]; return cell; }break; case CollectDataType_InterMail:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell2:tableView indexPath:indexPath]; cell.cell1IconImageView.image = IMG(@"站内信图"); cell.cell1TitleLabel.text = dataModel.Title; cell.cell1Authorlabel.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的收藏",dataModel.Author] KeyString:dataModel.Author]; return cell; }break; case CollectDataType_Group:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell2:tableView indexPath:indexPath]; cell.cell1IconImageView.image = IMG(@"笔记小组"); cell.cell1TitleLabel.text = dataModel.Title; cell.cell1Authorlabel.text = dataModel.Author; return cell; }break; case CollectDataType_Approval:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell2:tableView indexPath:indexPath]; cell.cell1IconImageView.image = IMG(@"审批"); cell.cell1TitleLabel.text = dataModel.Title; cell.cell1Authorlabel.text = dataModel.Author; return cell; }break; default:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell2:tableView indexPath:indexPath]; cell.cell1IconImageView.image = IMG(@"笔记群聊"); cell.cell1TitleLabel.text = dataModel.Title; cell.cell1Authorlabel.text = dataModel.Author; return cell; }break; } }break; } }break; } }break; case InterLeterDetialType_Sign :{ InterLeterDetailSubModel * model = self.interLetterArray[indexPath.section]; switch (indexPath.row) { case 0: { NoteBookDetailCell *cell = [NoteBookDetailCell configCell6:tableView indexPath:indexPath]; cell.cellArticleTitleLabel.text = model.Title; self.replayTitle = model.Title; if(model.AddresseeUsers.count == 0){ cell.cellArticleAuthor2Label.attributedText = [[NSAttributedString alloc] initWithString:@"收件人:--"]; }else{ NSMutableArray * userArray = [[NSMutableArray alloc] init]; for (InterLeterAddresseeUsers * userModel in model.AddresseeUsers) { [userArray addObject:userModel.Name]; } NSString * NoticeAddresseeNames = [NSString stringWithFormat:@"收件人: %@",[userArray componentsJoinedByString:@"、"]]; [cell layoutIfNeeded]; [self setCellLabel:cell.cellArticleAuthor2Label withText:NoticeAddresseeNames indexPath:indexPath isShow:self.labelShow]; UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithActionBlock:^(id _Nonnull sender) { weakSelf.labelShow = !weakSelf.labelShow; [weakSelf.tableView reloadRowAtIndexPath:indexPath withRowAnimation:UITableViewRowAnimationAutomatic]; }]; [cell.cellArticleAuthor2Label addGestureRecognizer:tap]; cell.cellArticleAuthor2Label.userInteractionEnabled = YES; } cell.cellArticleAuthorLabel.text = [NSString stringWithFormat:@"%@",model.UserName]; cell.cellArticleTimeLabel.numberOfLines = 1; cell.cellArticleTimeLabel.text = [NSDate getCHtimeWihtDate:model.CreatedDate]; cell.cellArticleReadNumberLabel.text = [NSString stringWithFormat:@"%ld",(long)model.ReadCount]; cell.cellArticleAllReadNumberLabel.text = [NSString stringWithFormat:@"/%ld",(long)model.AllCount]; [cell.cellArticleDeleteButton setTitle:@"撤回" forState:UIControlStateNormal]; WS(weakSelf); [cell.checkReadButton setAction:^{ [weakSelf checkRead]; }]; [cell.checkPeopleButton setAction:^{ [weakSelf checkReadUserId:model.UserId]; }]; if (model.IsRecall) { cell.cellArticleDeleteButton.hidden = NO; if ([AppUserModel sharedAppUserModel].Id == model.UserId) { cell.cellArticleEditorButton.hidden = NO; }else{ cell.cellArticleEditorButton.hidden = YES; }; }else{ if ([AppUserModel sharedAppUserModel].Id == model.UserId) { cell.cellArticleDeleteButton.hidden = YES; cell.cellArticleEditorButton.hidden = NO; }else{ cell.cellArticleDeleteButton.hidden = YES; cell.cellArticleEditorButton.hidden = YES; }; } [cell.cellArticleDeleteButton setAction:^{ [weakSelf ReCallMessage:model.Id]; }]; [cell.cellArticleEditorButton setAction:^{ [weakSelf editMissive:model.Id]; }]; return cell; } break; default:{ InterLeterDetailDataModel *dataModel = model.Data[indexPath.row-1]; switch (dataModel.Type) { case CollectDataType_Text:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell1:tableView indexPath:indexPath]; cell.cell0ImgTitleLab.text = dataModel.Text; return cell; }break; case CollectDataType_IMG:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell0:tableView indexPath:indexPath]; [cell.cell0ImgView sd_setImageWithURL:[NSURL URLWithString:dataModel.File] placeholderImage:IMG(@"img_placeHolder")completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { [self.tableView reloadRowAtIndexPath:indexPath withRowAnimation:UITableViewRowAnimationAutomatic]; }]; return cell; }break; case CollectDataType_File:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell2:tableView indexPath:indexPath]; NSString * imageName = [ZYCTool getFileNameImage:dataModel.File]; if (imageName.length > 0) { cell.cell1IconImageView.image = IMG(imageName); }else{ [cell.cell1IconImageView sd_setImageWithURL:[NSURL URLWithString:dataModel.File] placeholderImage:IMG(@"icon_weizhiwenjian")]; } cell.cell1IconImageView.image = IMG(imageName); cell.cell1TitleLabel.text = dataModel.FileName; cell.cell1Authorlabel.text = dataModel.Author; return cell; }break; case CollectDataType_Article:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell2:tableView indexPath:indexPath]; switch (dataModel.ArticleImgUrl.count) { case 0:{ cell.cell1IconImageView.image = IMG(@"icon_myPaper"); }break; default:{ [cell.cell1IconImageView sd_setImageWithURL:[NSURL URLWithString:dataModel.ArticleImgUrl.firstObject] placeholderImage:IMG(@"img_placeHolder")completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {}]; }break; } [cell.cell1IconImageView sd_setImageWithURL:[NSURL URLWithString:dataModel.File] placeholderImage:IMG(@"img_placeHolder")completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { }]; cell.cell1TitleLabel.text = dataModel.FileName; cell.cell1Authorlabel.text = dataModel.Author; return cell; }break; case CollectDataType_Notice:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell2:tableView indexPath:indexPath]; cell.cell1IconImageView.image = IMG(@"通知图标"); cell.cell1TitleLabel.text = dataModel.Title; cell.cell1Authorlabel.text = dataModel.Author; return cell; }break; case CollectDataType_Topic:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell2:tableView indexPath:indexPath]; cell.cell1IconImageView.image = IMG(@"话题"); cell.cell1TitleLabel.text = dataModel.Title; cell.cell1Authorlabel.text = dataModel.Author; return cell; }break; case CollectDataType_Note:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell2:tableView indexPath:indexPath]; cell.cell1IconImageView.image = IMG(@"noteBook_icon"); cell.cell1TitleLabel.text = dataModel.Title; cell.cell1Authorlabel.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的笔记",dataModel.Author] KeyString:dataModel.Author]; return cell; }break; case CollectDataType_Collect:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell2:tableView indexPath:indexPath]; cell.cell1IconImageView.image = IMG(@"收藏"); cell.cell1TitleLabel.text = dataModel.Title; cell.cell1Authorlabel.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的收藏",dataModel.Author] KeyString:dataModel.Author]; return cell; }break; case CollectDataType_InterMail:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell2:tableView indexPath:indexPath]; cell.cell1IconImageView.image = IMG(@"站内信图"); cell.cell1TitleLabel.text = dataModel.Title; cell.cell1Authorlabel.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的收藏",dataModel.Author] KeyString:dataModel.Author]; return cell; }break; case CollectDataType_Group:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell2:tableView indexPath:indexPath]; cell.cell1IconImageView.image = IMG(@"笔记小组"); cell.cell1TitleLabel.text = dataModel.Title; cell.cell1Authorlabel.text = dataModel.Author; return cell; }break; case CollectDataType_Approval:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell2:tableView indexPath:indexPath]; cell.cell1IconImageView.image = IMG(@"审批"); cell.cell1TitleLabel.text = dataModel.Title; cell.cell1Authorlabel.text = dataModel.Author; return cell; }break; default:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell2:tableView indexPath:indexPath]; cell.cell1IconImageView.image = IMG(@"笔记群聊"); cell.cell1TitleLabel.text = dataModel.Title; cell.cell1Authorlabel.text = dataModel.Author; return cell; }break; } } break; } }break; case InterLeterDetialType_NoSign :{ InterLeterDetailSubModel * model = self.interLetterArray[indexPath.section]; switch (indexPath.row) { case 0: { NoteBookDetailCell *cell = [NoteBookDetailCell configCell7:tableView indexPath:indexPath]; cell.cellArticleTitleLabel.text = model.Title; self.replayTitle = model.Title; [cell.cellArticleDeleteButton setTitle:@"撤回" forState:UIControlStateNormal]; if(model.AddresseeUsers.count == 0){ cell.cellArticleAuthor2Label.attributedText = [[NSAttributedString alloc] initWithString:@"收件人:--"]; }else{ NSMutableArray * userArray = [[NSMutableArray alloc] init]; for (InterLeterAddresseeUsers * userModel in model.AddresseeUsers) { [userArray addObject:userModel.Name]; } NSString * NoticeAddresseeNames = [NSString stringWithFormat:@"收件人: %@",[userArray componentsJoinedByString:@"、"]]; [cell layoutIfNeeded]; [self setCellLabel:cell.cellArticleAuthor2Label withText:NoticeAddresseeNames indexPath:indexPath isShow:self.labelShow]; UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithActionBlock:^(id _Nonnull sender) { weakSelf.labelShow = !weakSelf.labelShow; [weakSelf.tableView reloadRowAtIndexPath:indexPath withRowAnimation:UITableViewRowAnimationAutomatic]; }]; [cell.cellArticleAuthor2Label addGestureRecognizer:tap]; cell.cellArticleAuthor2Label.userInteractionEnabled = YES; } cell.cellArticleTimeLabel.numberOfLines = 1; cell.cellArticleTimeLabel.text = [NSDate getCHtimeWihtDate:model.CreatedDate]; if (model.IsAdmin) { cell.cellArticleEditorButton.hidden = NO; cell.cellArticleDeleteButton.hidden = NO; }else{ cell.cellArticleEditorButton.hidden = YES; cell.cellArticleDeleteButton.hidden = YES; } WS(weakSelf); [cell.cellArticleDeleteButton setAction:^{ [weakSelf deleteButtonHander:model.Id]; }]; [cell.cellArticleEditorButton setAction:^{ [weakSelf editorButtonHander:model.Id]; }]; return cell; } break; default:{ InterLeterDetailDataModel *dataModel = model.Data[indexPath.row-1]; switch (dataModel.Type) { case CollectDataType_Text:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell1:tableView indexPath:indexPath]; cell.cell0ImgTitleLab.text = dataModel.Text; return cell; }break; case CollectDataType_IMG:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell0:tableView indexPath:indexPath]; [cell.cell0ImgView sd_setImageWithURL:[NSURL URLWithString:dataModel.File] placeholderImage:IMG(@"img_placeHolder")completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { [self.tableView reloadRowAtIndexPath:indexPath withRowAnimation:UITableViewRowAnimationAutomatic]; }]; return cell; }break; case CollectDataType_File:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell2:tableView indexPath:indexPath]; NSString * imageName = [ZYCTool getFileNameImage:dataModel.File]; if (imageName.length > 0) { cell.cell1IconImageView.image = IMG(imageName); }else{ [cell.cell1IconImageView sd_setImageWithURL:[NSURL URLWithString:dataModel.File] placeholderImage:IMG(@"icon_weizhiwenjian")]; } cell.cell1IconImageView.image = IMG(imageName); cell.cell1TitleLabel.text = dataModel.FileName; cell.cell1Authorlabel.text = dataModel.Author; return cell; }break; case CollectDataType_Article:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell2:tableView indexPath:indexPath]; switch (dataModel.ArticleImgUrl.count) { case 0:{ cell.cell1IconImageView.image = IMG(@"icon_myPaper"); }break; default:{ [cell.cell1IconImageView sd_setImageWithURL:[NSURL URLWithString:dataModel.ArticleImgUrl.firstObject] placeholderImage:IMG(@"img_placeHolder")completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {}]; }break; } [cell.cell1IconImageView sd_setImageWithURL:[NSURL URLWithString:dataModel.File] placeholderImage:IMG(@"img_placeHolder")completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { }]; cell.cell1TitleLabel.text = dataModel.FileName; cell.cell1Authorlabel.text = dataModel.Author; return cell; }break; case CollectDataType_Notice:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell2:tableView indexPath:indexPath]; cell.cell1IconImageView.image = IMG(@"通知图标"); cell.cell1TitleLabel.text = dataModel.Title; cell.cell1Authorlabel.text = dataModel.Author; return cell; }break; case CollectDataType_Topic:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell2:tableView indexPath:indexPath]; cell.cell1IconImageView.image = IMG(@"话题"); cell.cell1TitleLabel.text = dataModel.Title; cell.cell1Authorlabel.text = dataModel.Author; return cell; }break; case CollectDataType_Note:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell2:tableView indexPath:indexPath]; cell.cell1IconImageView.image = IMG(@"noteBook_icon"); cell.cell1TitleLabel.text = dataModel.Title; cell.cell1Authorlabel.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的笔记",dataModel.Author] KeyString:dataModel.Author]; return cell; }break; case CollectDataType_Collect:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell2:tableView indexPath:indexPath]; cell.cell1IconImageView.image = IMG(@"收藏"); cell.cell1TitleLabel.text = dataModel.Title; cell.cell1Authorlabel.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的收藏",dataModel.Author] KeyString:dataModel.Author]; return cell; }break; case CollectDataType_InterMail:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell2:tableView indexPath:indexPath]; cell.cell1IconImageView.image = IMG(@"站内信图"); cell.cell1TitleLabel.text = dataModel.Title; cell.cell1Authorlabel.attributedText = [ZYCTool checkOfString:[NSString stringWithFormat:@"来自-%@的收藏",dataModel.Author] KeyString:dataModel.Author]; return cell; }break; case CollectDataType_Group:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell2:tableView indexPath:indexPath]; cell.cell1IconImageView.image = IMG(@"笔记小组"); cell.cell1TitleLabel.text = dataModel.Title; cell.cell1Authorlabel.text = dataModel.Author; return cell; }break; case CollectDataType_Approval:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell2:tableView indexPath:indexPath]; cell.cell1IconImageView.image = IMG(@"审批"); cell.cell1TitleLabel.text = dataModel.Title; cell.cell1Authorlabel.text = dataModel.Author; return cell; }break; default:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell2:tableView indexPath:indexPath]; cell.cell1IconImageView.image = IMG(@"笔记群聊"); cell.cell1TitleLabel.text = dataModel.Title; cell.cell1Authorlabel.text = dataModel.Author; return cell; }break; } } break; } }break; default:{ NoteBookDetailCell *cell = [NoteBookDetailCell configCell2:tableView indexPath:indexPath]; return cell; } break; } } - (void)deleteButtonHander:(NSInteger)interLeterID{ NSMutableDictionary *dic = [[NSMutableDictionary alloc]init]; [dic setValue:@[@(interLeterID)] forKey:@"MiddleIds"]; [dic setValue:@(5) forKey:@"FolderType"]; SHOWLOADING WS(weakSelf); [[HttpManager sharedHttpManager] POSTUrl:Host(API_Find_DeleteRecord) parameters:dic responseStyle:DATA success:^(id _Nonnull responseObject) { REMOVESHOW [weakSelf.navigationController popViewControllerAnimated:YES]; } failure:^(NSError * _Nonnull error) { SHOWERROR([ZYCTool handerResultData:error]); }]; } - (void)editorButtonHander:(NSInteger)interLeterID{ CreateInterLeterVC *vc = [CreateInterLeterVC initCreateInterLeterVC]; vc.interLeterId = interLeterID; vc.interLeterHanderType = InterLeterHanderType_Modify; vc.modifyArray = self.interLetterArray; [self.navigationController pushViewController:vc animated:YES]; } - (void)gotoCollectHander{ MoveViewController *vc = [MoveViewController initMoveViewController]; vc.CollectionDataId = self.interLeterID; vc.collectType = CollectHanderType_Collect; vc.ParentId = 0; vc.titleStr = @"我的收藏"; vc.TypeId = CreateCollectionType; vc.FolderIds = @[].mutableCopy; vc.CollectionType = 6; [self.navigationController pushViewController:vc animated:YES]; } - (void)shareHander{ [self.noteBookShareVC initNoteBookShareData]; self.noteBookShareVC.view.hidden = !self.noteBookShareVC.view.hidden; } - (NoteBookShareVC *)noteBookShareVC{ if (_noteBookShareVC == nil) { _noteBookShareVC = [NoteBookShareVC initNoteBookShareVC]; [_noteBookShareVC.view setFrame:CGRectMake(0,0, SCREEN_WIDTH, SCREEN_HEIGHT)]; [_noteBookShareVC.view setHidden:YES]; _noteBookShareVC.delegate = self; } return _noteBookShareVC; } -(void)userSelectType:(NSString *)typeName WithIndexPath:(NSIndexPath *)indexPath{ self.noteBookShareVC.view.hidden = !self.noteBookShareVC.view.hidden; if ([typeName isEqualToString:@"发给微信好友"]) { }else if ([typeName isEqualToString:@"发到朋友圈"]){ }else if ([typeName isEqualToString:@"发到微博"]){ }else if ([typeName isEqualToString:@"发给QQ好友"]){ }else if ([typeName isEqualToString:@"发到消息"]){ }else if ([typeName isEqualToString:@"发到小组"]){ [self returnToGroup]; }else if ([typeName isEqualToString:@"发到笔记"]){ [self returnToNote]; }else if ([typeName isEqualToString:@"发到话题"]){ [self returnToTopic]; }else{ } } - (void)returnToGroup { MyTDGroupViewController * vc = [[MyTDGroupViewController alloc] init]; NewTopicModel * model = [[NewTopicModel alloc] init]; model.type = CollectDataType_InterMail; model.title = self.currentDetailModel.Title; model.FileId = self.currentDetailModel.Id; model.AuthorName = self.currentDetailModel.SendName; model.FileName = self.currentDetailModel.Title; vc.sendModel = model; vc.isReturn = YES; [self.navigationController pushViewController:vc animated:YES]; } - (void)returnToNote { MoveViewController * vc = [MoveViewController initMoveViewController]; vc.TypeId = CreateNotesType; vc.ParentId = 0; vc.titleStr = @"我的笔记"; NewTopicModel * model = [[NewTopicModel alloc] init]; model.type = CollectDataType_InterMail; model.title = self.currentDetailModel.Title; model.FileId = self.currentDetailModel.Id; model.AuthorName = self.currentDetailModel.SendName; model.FileName = self.currentDetailModel.Title; vc.sendModel = model; vc.isReturn = YES; [self.navigationController pushViewController:vc animated:YES]; } - (void)returnToTopic { MyTDTopicCreateVC * vc = [MyTDTopicCreateVC initMyTDTopicCreateVC]; NewTopicModel * model = [[NewTopicModel alloc] init]; model.type = CollectDataType_InterMail; model.title = self.currentDetailModel.Title; model.FileId = self.currentDetailModel.Id; model.AuthorName = self.currentDetailModel.SendName; model.FileName = self.currentDetailModel.Title; vc.sendModel = model; vc.isReturn = YES; [self.navigationController pushViewController:vc animated:YES]; } - (void)gotoZanHander{ NSMutableDictionary *dic = [NSMutableDictionary dictionary]; [dic setValue:@(self.currentDetailModel.Id) forKey:@"SourceId"]; [dic setValue:@([AppUserModel sharedAppUserModel].Id) forKey:@"UserId"]; [dic setValue:@(1) forKey:@"AnalyzeType"];//详情点赞 [dic setValue:@(4) forKey:@"TypeValue"];//笔记 3 WS(weakSelf); [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Analyze_Set) parameters:dic responseStyle:DATA success:^(id _Nonnull responseObject) { [weakSelf getData]; } failure:^(NSError * _Nonnull error) { SHOWERROR([ZYCTool handerResultData:error]); }]; } - (void)checkRead{ InterLeterDetailSubModel * model = self.interLetterArray.firstObject; NoticeUnreadVC *vc = [NoticeUnreadVC initNoticeUnreadVC]; vc.Id = model.Id; vc.type = ReadMissiveType; vc.readCount = model.ReadCount; vc.unReadCount = model.AllCount - model.ReadCount; [self.navigationController pushViewController:vc animated:YES]; } - (void)checkReadUserId:(NSInteger )userId{ MailListDetailVC *vc = [MailListDetailVC initMailListDetailVC]; vc.indexId = userId; [self.navigationController pushViewController:vc animated:YES]; } - (void)commentHander{ UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet]; UIAlertAction *alertAction1 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { }]; [alertAction1 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"]; WS(weakSelf); UIAlertAction *alertAction2 = [UIAlertAction actionWithTitle:@"回复" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { CreateInterLeterVC *vc = [CreateInterLeterVC initCreateInterLeterVC]; vc.interLeterHanderType = InterLeterHanderType_Replay; vc.replayId = weakSelf.interLeterID; vc.replayArray = weakSelf.interLetterArray; vc.replayDataArray = [NSMutableArray arrayWithArray:@[weakSelf.detailModel.missiveAddressee]]; vc.replayTitle = weakSelf.replayTitle; [weakSelf.navigationController pushViewController:vc animated:YES]; }]; [alertAction2 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"]; UIAlertAction *alertAction3 = [UIAlertAction actionWithTitle:@"回复全部" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { CreateInterLeterVC *vc = [CreateInterLeterVC initCreateInterLeterVC]; vc.interLeterHanderType = InterLeterHanderType_Replay; vc.replayId = weakSelf.interLeterID; vc.replayArray = weakSelf.interLetterArray; vc.replayDataArray = [NSMutableArray arrayWithArray:weakSelf.detailModel.missiveAddressees]; vc.replayTitle = weakSelf.replayTitle; [weakSelf.navigationController pushViewController:vc animated:YES]; }]; [alertAction3 setValue:UIColorHex(#0A0A0A) forKey:@"titleTextColor"]; [alert addAction:alertAction2]; [alert addAction:alertAction3]; [alert addAction:alertAction1]; [self presentViewController:alert animated:YES completion:^{ }]; } #pragma mark - 撤回站内信 - (void)ReCallMessage:(NSInteger)Id { NSString * url = [NSString stringWithFormat:@"%@%ld",Host(API_APP_Missive_Recall),(long)Id]; SHOWLOADING WS(weakSelf); [[HttpManager sharedHttpManager] PUTUrl:url parameters:@{} responseStyle:DATA success:^(id _Nonnull responseObject) { REMOVESHOW [weakSelf.navigationController popViewControllerAnimated:YES]; } failure:^(NSError * _Nonnull error) { REMOVESHOW SHOWERROR(@"站内信超过撤回时间") }]; } - (void)editMissive:(NSInteger)Id { CreateInterLeterVC *vc = [CreateInterLeterVC initCreateInterLeterVC]; vc.interLeterHanderType = InterLeterHanderType_Modify; vc.isEdit = YES; vc.interLeterId = Id; [self.navigationController pushViewController:vc animated:YES]; } - (void)setCellLabel:(UILabel *)label withText:(NSString *)text indexPath:(NSIndexPath *)indexPath isShow:(BOOL)isShow { NSArray * stringArr = [self getLinesArrayOfStringInText:text width:label.frame.size.width]; if (stringArr.count > 2) { if (isShow) { NSString *upStr = @" 收起"; NSString *string1 = stringArr[0]; NSString *string2 = stringArr.lastObject; NSString *string3 = [NSString stringWithFormat:@"%@%@",string2,upStr]; if (string3.length > string1.length) { upStr = [NSString stringWithFormat:@"%@\n%@",text,upStr]; }else{ upStr = [NSString stringWithFormat:@"%@%@",text,upStr]; } label.attributedText = [self AttributedwithText:upStr]; label.numberOfLines = 0; }else{ label.numberOfLines = 2; NSString *string1 = stringArr[0]; NSString *string2 = stringArr[1]; string2 = [string2 substringToIndex:string2.length - 6]; NSString *string3 = [NSString stringWithFormat:@"%@%@... 展开",string1,string2]; label.attributedText = [self AttributedwithText:string3]; } }else{ label.attributedText = [[NSAttributedString alloc] initWithString:text]; } } - (NSAttributedString *)AttributedwithText:(NSString *)text { NSMutableAttributedString *mutableAttributedString = [[NSMutableAttributedString alloc] initWithString:text]; [mutableAttributedString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:NSMakeRange(0, text.length)]; [mutableAttributedString addAttribute:NSForegroundColorAttributeName value:UIColorHex(0x999999) range:NSMakeRange(0, text.length - 2)]; [mutableAttributedString addAttribute:NSForegroundColorAttributeName value:UIColorHex(0x1F87DB) range:NSMakeRange(text.length - 2, 2)]; return mutableAttributedString; } - (NSArray *)getLinesArrayOfStringInText:(NSString *)text width:(CGFloat)width{ UIFont *font = [UIFont systemFontOfSize:14]; CTFontRef myFont = CTFontCreateWithName((CFStringRef)([font fontName]), [font pointSize], NULL); NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc] initWithString:text]; [attStr addAttribute:(NSString *)kCTFontAttributeName value:(__bridge id)myFont range:NSMakeRange(0, attStr.length)]; CFRelease(myFont); CTFramesetterRef frameSetter = CTFramesetterCreateWithAttributedString(( CFAttributedStringRef)attStr); CGMutablePathRef path = CGPathCreateMutable(); CGPathAddRect(path, NULL, CGRectMake(0,0,width,100000)); CTFrameRef frame = CTFramesetterCreateFrame(frameSetter, CFRangeMake(0, 0), path, NULL); NSArray *lines = ( NSArray *)CTFrameGetLines(frame); NSMutableArray *linesArray = [[NSMutableArray alloc]init]; for (id line in lines) { CTLineRef lineRef = (__bridge CTLineRef )line; CFRange lineRange = CTLineGetStringRange(lineRef); NSRange range = NSMakeRange(lineRange.location, lineRange.length); NSString *lineString = [text substringWithRange:range]; CFAttributedStringSetAttribute((CFMutableAttributedStringRef)attStr, lineRange, kCTKernAttributeName, (CFTypeRef)([NSNumber numberWithFloat:0.0])); CFAttributedStringSetAttribute((CFMutableAttributedStringRef)attStr, lineRange, kCTKernAttributeName, (CFTypeRef)([NSNumber numberWithInt:0.0])); [linesArray addObject:lineString]; } CGPathRelease(path); CFRelease( frame ); CFRelease(frameSetter); return (NSArray *)linesArray; } @end