123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558 |
- //
- // MyTDTopicSelectExtentVC.m
- // smartRhino
- //
- // Created by niuzhen on 2019/12/20.
- // Copyright © 2019 tederen. All rights reserved.
- //
- #import "MyTDTopicSelectExtentVC.h"
- #import "MyTDTopicSelectExtentCell.h"
- #import "MyTDTSEModel.h"
- #import "YCMenuView.h"
- #import "MyFavoriteNewFindVC.h"
- @interface MyTDTopicSelectExtentVC ()<UITableViewDelegate, UITableViewDataSource>
- @property (weak, nonatomic) IBOutlet UIButton *addBtn;
- @property (weak, nonatomic) IBOutlet UILabel *titleL;
- @property (weak, nonatomic) IBOutlet UIButton *menuBtn;
- @property (assign,nonatomic) OperationStateEnum operationStateEnum;
- @property (weak, nonatomic) IBOutlet UIButton *operationAllSelectButton;
- @property (strong,nonatomic) UIView *operationBottomBgView;
- @property (weak, nonatomic) IBOutlet UIView *noDataView;
- @property (weak, nonatomic) IBOutlet UIButton *noDataBtn;
- @property (weak, nonatomic) IBOutlet UITableView *tableView;
- @property (strong, nonatomic) NSMutableArray *dataArray;
- @property (nonatomic, copy) NSArray *addListArray;
- @property (nonatomic, strong) UIButton *leftCloseBtn;
- @property (nonatomic, assign) BOOL iSViewEditor;
- @property (nonatomic, assign) BOOL isAllselect;
- @end
- @implementation MyTDTopicSelectExtentVC
- +(MyTDTopicSelectExtentVC *)initMyTDTopicSelectExtentVC
- {
- MyTDTopicSelectExtentVC *controller = [StoryboardManager.shared.myTDTopicExtent instantiateViewControllerWithIdentifier:@"MyTDTopicSelectExtentVC"];
- return controller;
- }
- - (void)viewWillAppear:(BOOL)animated
- {
- [super viewWillAppear:animated];
- [self getData];
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.titleL.text = self.titleStr;
- self.iSViewEditor = NO;
- if (@available(iOS 11.0, *)) {
- self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
- }else {
- self.automaticallyAdjustsScrollViewInsets = NO;
- }
- self.fd_prefersNavigationBarHidden = YES;
- [self initBottomBgView];
- [self changeToOperation:NO];
- self.tableView.delegate = self;
- self.tableView.dataSource = self;
- WS(weakSelf);
- [self.operationAllSelectButton setTitle:@"全选" forState:UIControlStateNormal];
- [self.operationAllSelectButton setAction:^{
- for (MyTDTSEModel * model in weakSelf.dataArray) {
- model.isSelect = !weakSelf.isAllselect;
- }
- [self.tableView reloadData];
- }];
- [self.noDataBtn setAction:^{
- MyFavoriteNewFindVC *vc = [MyFavoriteNewFindVC initMyFavoriteNewFindVC];
- vc.ParentId = weakSelf.folderId;
- vc.createFoldType = CreateNotesType;
- vc.modifyTye = CreateType;
- vc.fileType = NewTopicFileType;
- [weakSelf.navigationController pushViewController:vc animated:YES];
- }];
- }
- - (void)setOperationAllButton {
- // 设置导航栏全选按钮
- self.isAllselect = [self checkChatListArray];
- if (self.isAllselect) {
- [self.operationAllSelectButton setTitle:@"取消全选" forState:UIControlStateNormal];
- }else{
- [self.operationAllSelectButton setTitle:@"全选" forState:UIControlStateNormal];
- }
- }
- - (BOOL)checkChatListArray
- {
- for (MyTDTSEModel * model in self.dataArray) {
- if (!model.isSelect) {
- return NO;
- }
- }
- return YES;
- }
- - (void)upDateAddBtn
- {
- WS(weakSelf);
- if (self.isSubVC) {
- self.addListArray = self.dataArray.count == 0 ? @[@"共享范围",@"建文件夹"] : @[@"共享范围",@"建文件夹",@"批量编辑"];
- }else{
- self.addListArray = self.dataArray.count == 0 ? @[@"建文件夹"] : @[@"建文件夹",@"批量编辑"];
- }
- [self.addBtn setAction:^{
- NSMutableArray *menuDataSourceArray = [weakSelf getMenuDataSource:weakSelf.addListArray];
- YCMenuView *view = [YCMenuView menuWithActions:menuDataSourceArray width:106 relyonView:weakSelf.addBtn];
- view.menuColor = RGB(255, 255, 255);
- view.separatorColor = RGB(234, 234, 234);
- view.textColor = RGB(102, 102, 102);
- view.textFont = [UIFont systemFontOfSize:16.0];
- view.menuCellHeight = 43.5;
- view.maxDisplayCount = 10;
- view.offset = -6;
- [view show];
- }];
- }
- -(NSMutableArray *)getMenuDataSource:(NSArray *)titleArray{
- NSMutableArray *menuDataSourceArray = [[NSMutableArray alloc] init];
- for(int i = 0;i<titleArray.count;i++){
- NSString *titleStr = [titleArray objectAtIndex:i];
- WS(weakSelf);
- YCMenuAction *actionMenu = [YCMenuAction actionWithTitle:titleStr image:nil handler:^(YCMenuAction *action) {
- if([@"建文件夹" isEqualToString:action.title]){
- MyFavoriteNewFindVC *vc = [MyFavoriteNewFindVC initMyFavoriteNewFindVC];
- vc.ParentId = weakSelf.folderId;
- vc.createFoldType = CreateNotesType;
- vc.modifyTye = CreateType;
- vc.fileType = NewTopicFileType;
- [weakSelf.navigationController pushViewController:vc animated:YES];
- }else if ([@"批量编辑" isEqualToString:action.title]){
- [weakSelf changeToOperation:YES];
- }else if ([@"共享范围" isEqualToString:action.title]){
- MyFavoriteNewFindVC *vc = [MyFavoriteNewFindVC initMyFavoriteNewFindVC];
- vc.ParentId = weakSelf.ParentId;
- vc.createFoldType = CreateNotesType;
- vc.foldId = weakSelf.folderId;
- vc.modifyTye = ModifyType;
- vc.fileType = NewOtherFileType;
- vc.titleStr = @"修改文件夹";
- vc.fileName = self.fileName;
- [weakSelf.navigationController pushViewController:vc animated:YES];
-
- }
- }];
- [menuDataSourceArray addObject:actionMenu];
- }
- return menuDataSourceArray;
- }
- #pragma Mark 左滑按钮 iOS8以上
- #if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_11_0
- - (UISwipeActionsConfiguration *)tableView:(UITableView *)tableView trailingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(tvos){// delete action
- WS(weakSelf);
- MyTDTSEModel * model = [self.dataArray objectAtIndex:indexPath.row];
- UIContextualAction *action1 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"删除" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) {
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
- UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
- [weakSelf deleteFind:@[@(model.Id)]];
- }];
- UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
- }];
- [alert addAction:sureAction];
- [alert addAction:cancelAction];
- [weakSelf presentViewController:alert animated:YES completion:^{
-
- }];
- }];
- action1.backgroundColor = RGB(255, 59, 47);
- UIContextualAction *action2 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"修改" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) {
- MyFavoriteNewFindVC *vc = [MyFavoriteNewFindVC initMyFavoriteNewFindVC];
- vc.ParentId = model.Id;
- vc.foldId = model.Id;
- vc.createFoldType = CreateNotesType;
- vc.modifyTye = ModifyType;
- vc.fileType = NewOtherFileType;
- vc.fileName = self.fileName;
- [weakSelf.navigationController pushViewController:vc animated:YES];
- }];
- action2.backgroundColor = UIColorHex(#FF923A);
- UIContextualAction *action3 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:model.IsTop?@"取消置顶" :@"置顶" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) {
- [weakSelf topFind:model];
- }];
- action3.backgroundColor = UIColorHex(#9BA9CB);
- UISwipeActionsConfiguration *actions = [UISwipeActionsConfiguration configurationWithActions:@[action1,action2,action3]];
- actions.performsFirstActionWithFullSwipe = NO;
- return actions;
- }
- #else
- - (NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
- MyTDTSEModel * model = [self.dataArray objectAtIndex:indexPath.row];
- WEAKSELF
- UITableViewRowAction *action1 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"删除" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
- [weakSelf deleteFind:@[@(model.Id)]];
- }];
- action1.backgroundColor = RGB(255, 59, 47);
- UITableViewRowAction *action2 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"修改" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
- MyFavoriteNewFindVC *vc = [MyFavoriteNewFindVC initMyFavoriteNewFindVC];
- vc.ParentId = model.Id;
- vc.foldId = model.Id;
- vc.createFoldType = CreateNotesType;
- vc.modifyTye = ModifyType;
- vc.fileType = NewOtherFileType;
- vc.fileName = self.fileName;
- [weakSelf.navigationController pushViewController:vc animated:YES];
- }];
- action2.backgroundColor = UIColorHex(#FF923A);
- UITableViewRowAction *action3 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title: model.IsTop?@"取消置顶" :@"置顶" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
- [weakSelf topFind:model];
- }];
- action3.backgroundColor = UIColorHex(#9BA9CB);
- return @[action1, action2, action3];
- }
- #endif
- -(void)initBottomBgView{
- self.leftCloseBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [self.leftCloseBtn setTitle:@"删除" forState:UIControlStateNormal];
- [self.leftCloseBtn setTitleColor:RGB(255, 82, 82) forState:UIControlStateNormal];
- self.leftCloseBtn.titleLabel.font = [UIFont systemFontOfSize:15];
-
- [self.operationBottomBgView addSubview:self.leftCloseBtn];
- self.leftCloseBtn.frame = CGRectMake(0, 10, SCREEN_WIDTH, self.operationBottomBgView.height - 10);
-
-
- UIView *topLine = [[UIView alloc] init];
- topLine.backgroundColor = RGB(240, 239, 244);
- [self.operationBottomBgView addSubview:topLine];
- topLine.frame = CGRectMake(0, 0, SCREEN_WIDTH, 10);
-
- WS(weakSelf);
- [self.leftCloseBtn setAction:^{
- NSMutableArray *selectIDArray = [NSMutableArray array];
- for (MyTDTSEModel * model in weakSelf.dataArray) {
- if (model.isSelect) {
- [selectIDArray addObject:@(model.Id)];
- }
- }
- if (selectIDArray.count == 0) {
- SHOWERROR(@"请选择要删除的通知");
- return ;
- }else{
- [weakSelf deleteFind:selectIDArray];
- }
- }];
- [[UtilsTools getWindow] addSubview:self.operationBottomBgView];
- }
- - (void)deleteFind:(NSArray *)array
- {
- NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
- [dic setValue:array forKey:@"MiddleIds"];
- [dic setValue:@(CreateNotesType) forKey:@"FolderType"];
- SHOWLOADING
- WEAKSELF
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_Find_DeleteRecord) parameters:dic responseStyle:DATA success:^(id _Nonnull responseObject) {
- STRONGSELF
- REMOVESHOW
- [strongSelf getData];
- } failure:^(NSError * _Nonnull error) {
- SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- - (void)topFind:(MyTDTSEModel*)findModel{
- SHOWLOADING
- WEAKSELF
- [[HttpManager sharedHttpManager] PUTUrl:[NSString stringWithFormat:@"%@%@%ld",BaseUrl,API_Find_Top,(long)findModel.Id] parameters:@{} success:^(id _Nonnull responseObject) {
- STRONGSELF
- REMOVESHOW
- [strongSelf getData];
- } failure:^(NSError * _Nonnull error) {
- SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- -(UIView *)operationBottomBgView{
- if(!_operationBottomBgView){
- _operationBottomBgView = [[UIView alloc] init];
- CGFloat bottomBgViewH = self.tabBarController.tabBar.height + 10;
- _operationBottomBgView.frame = CGRectMake(0, SCREEN_HEIGHT - bottomBgViewH, SCREEN_WIDTH, bottomBgViewH);
- _operationBottomBgView.backgroundColor = RGB(255, 255, 255);
- _operationBottomBgView.hidden = YES;
- }
- return _operationBottomBgView;
- }
- #pragma mark 批量操作与正常操作界面切换
- -(void)changeToOperation:(BOOL)operation{
- if(operation){
- self.iSViewEditor = YES;
- self.addBtn.hidden = YES;
- //默认操作状态为批量编辑状态
- self.menuBtn.hidden = YES;
- self.operationStateEnum = OperationStateEnum1;
- // self.operationBackButton.hidden = NO;
- self.operationAllSelectButton.hidden = NO;
-
- self.tabBarController.tabBar.hidden = YES;
-
- self.operationBottomBgView.hidden = NO;
- self.view.height -= self.tabBarController.tabBar.height;
- self.tableView.height -= self.tabBarController.tabBar.height;
- [self.view layoutIfNeeded];
- [self.tableView layoutIfNeeded];
- }else{
- self.addBtn.hidden = NO;
- self.iSViewEditor = NO;
- self.menuBtn.hidden = NO;
- //默认操作状态为无状态
- self.operationStateEnum = OperationStateEnum0;
- self.operationAllSelectButton.hidden = YES;
-
- self.tabBarController.tabBar.hidden = YES;
-
- self.tableView.height += self.tabBarController.tabBar.height;
- self.view.height += self.tabBarController.tabBar.height;
- [self.view layoutIfNeeded];
- [self.tableView layoutIfNeeded];
- self.operationBottomBgView.hidden = YES;
- }
- [self.tableView reloadData];
- }
- #pragma mark 移动 isEdit:当前是否为编辑状态
- -(void)userDidMove:(BOOL)move isEdit:(BOOL)isEdit{
- //移动
- if(move){
- //默认操作状态为移动状态
- self.operationStateEnum = OperationStateEnum2;
- self.addBtn.hidden = NO;
- [self resetRightBtnAction:NO];
-
- //隐藏tabBar - 并将TableView至底端
- self.tabBarController.tabBar.hidden = YES;
- self.view.height += self.tabBarController.tabBar.height;
- self.tableView.height += self.tabBarController.tabBar.height;
- [self.view layoutIfNeeded];
- [self.tableView layoutIfNeeded];
- //隐藏operationBottomBgView
- self.operationBottomBgView.hidden = YES;
- }
- else{
- //隐藏tabBar - 并将TableView至底端有tabBar.height的高
- self.tabBarController.tabBar.hidden = YES;
- self.view.height -= self.tabBarController.tabBar.height;
- self.tableView.height -= self.tabBarController.tabBar.height;
- [self.view layoutIfNeeded];
- [self.tableView layoutIfNeeded];
- //显示operationBottomBgView
- self.operationBottomBgView.hidden = NO;
-
- if(isEdit){
- self.operationStateEnum = OperationStateEnum1;
- self.addBtn.hidden = YES;
- [self resetRightBtnAction:YES];
- }else{
- [self changeToOperation:NO];
- }
- }
- [self.tableView reloadData];
- }
- -(void)resetRightBtnAction:(BOOL)isShowMenu{
- WS(weakSelf);
- if(isShowMenu){
- [self.addBtn setImage:[UIImage imageNamed:@"chatmsg_right_add_icon"] forState:UIControlStateNormal];
- [self.addBtn setAction:^{
- NSMutableArray *menuDataSourceArray = [weakSelf getMenuDataSource:weakSelf.addListArray];
- YCMenuView *view = [YCMenuView menuWithActions:menuDataSourceArray width:106 relyonView:weakSelf.addBtn];
- view.menuColor = RGB(255, 255, 255);
- view.separatorColor = RGB(234, 234, 234);
- view.textColor = RGB(102, 102, 102);
- view.textFont = [UIFont systemFontOfSize:16.0];
- view.menuCellHeight = 43.5;
- view.maxDisplayCount = 10;
- view.offset = -6;
- [view show];
- }];
- }else{
- [self.addBtn setImage:[UIImage imageNamed:@"chatmsg_right_fileadd_icon"] forState:UIControlStateNormal];
- [self.addBtn setAction:^{
- [ShowtipTool showErrorWithStatus:@"未做"];
- }];
- }
- }
- - (void)backAction:(id)sender{
- if (self.iSViewEditor) {
- [self changeToOperation:NO];
- }else{
- [self.navigationController popViewControllerAnimated:true];
- }
- }
- - (void)menuAction:(id)sender{
- [super menuAction:sender];
- }
- - (void)getData
- {
- WS(weakSelf);
- [self.dataArray removeAllObjects];
- NSMutableDictionary *dic = [NSMutableDictionary dictionary];
- [dic setValue:@(self.ParentId) forKey:@"ParentId"];
- [dic setValue:@(CreateNotesType) forKey:@"TypeId"];
- [dic setValue:@[@(self.folderId)] forKey:@"FolderIds"];
- [[HttpManager sharedHttpManager] POSTWithUrl:Host(API_APP_Middle_Search_Note_Folder) parameters:dic success:^(id _Nonnull responseObject) {
- NSLog(@"文件夹数据%@",responseObject);
- for (NSDictionary * dict in responseObject) {
- MyTDTSEModel * model = [MyTDTSEModel modelWithDictionary:dict];
- [weakSelf.dataArray addObject:model];
- }
- if (weakSelf.dataArray.count == 0) {
- weakSelf.tableView.hidden = YES;
- weakSelf.noDataView.hidden = NO;
- }else{
- dispatch_async(dispatch_get_main_queue(), ^{
- weakSelf.tableView.hidden = NO;
- weakSelf.noDataView.hidden = YES;
- [weakSelf upDateAddBtn];
- [weakSelf.tableView reloadData];
- });
- }
- } failure:^(NSError * _Nonnull error) {
- SHOWERROR([ZYCTool handerResultData:error]);
- }];
- }
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- {
- return 1;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return self.dataArray.count;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- return 70.f;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- WS(weakSelf);
- [self setOperationAllButton];
- MyTDTSEModel * model = [self.dataArray objectAtIndex:indexPath.row];
- switch (self.operationStateEnum) {
- case OperationStateEnum0:
- {
- switch (model.RoleId) {
- case 1:
- {
- MyTDTopicSelectExtentCell * cell = [MyTDTopicSelectExtentCell configCell0:tableView indexPath:indexPath];
- cell.NameL.text = model.Name;
- cell.fileImgV.image = IMG(@"find_1");
- cell.subNameL.text = @"公开";
- cell.IsTopImgV.hidden = !model.IsTop;
- [cell.comeBtn setAction:^{
- MyTDTopicSelectExtentVC * vc = [MyTDTopicSelectExtentVC initMyTDTopicSelectExtentVC];
- vc.ParentId = model.Id;
- vc.folderId = model.Id;
- vc.titleStr = model.Name;
- vc.isSubVC = YES;
- [weakSelf.navigationController pushViewController:vc animated:YES];
- }];
- return cell;
- }
- break;
- default:
- {
- MyTDTopicSelectExtentCell * cell = [MyTDTopicSelectExtentCell configCell0:tableView indexPath:indexPath];
- cell.NameL.text = model.Name;
- cell.fileImgV.image = IMG(@"find_1");
- cell.subNameL.text = [NSString stringWithFormat:@"共享给:%@",model.EnjoyUser];
- cell.IsTopImgV.hidden = !model.IsTop;
- [cell.comeBtn setAction:^{
- MyTDTopicSelectExtentVC * vc = [MyTDTopicSelectExtentVC initMyTDTopicSelectExtentVC];
- vc.ParentId = model.Id;
- vc.folderId = model.Id;
- vc.titleStr = model.Name;
- vc.isSubVC = YES;
- [weakSelf.navigationController pushViewController:vc animated:YES];
- }];
- return cell;
- }
- break;
- }
- }
- break;
- default:
- {
- switch (model.RoleId) {
- case 1:
- {
- MyTDTopicSelectExtentCell * cell = [MyTDTopicSelectExtentCell configCell1:tableView indexPath:indexPath];
- cell.NameL.text = model.Name;
- cell.fileImgV.image = IMG(@"find_1");
- cell.subNameL.text = @"公开";
- cell.IsTopImgV.hidden = !model.IsTop;
- cell.selectBtn.selected = model.isSelect;
- [cell.selectBtn setAction:^{
- model.isSelect = !model.isSelect;
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView reloadRowAtIndexPath:indexPath withRowAnimation:UITableViewRowAnimationNone];
- });
- }];
- return cell;
- }
- break;
- default:
- {
- MyTDTopicSelectExtentCell * cell = [MyTDTopicSelectExtentCell configCell1:tableView indexPath:indexPath];
- cell.NameL.text = model.Name;
- cell.fileImgV.image = IMG(@"find_1");
- cell.subNameL.text = [NSString stringWithFormat:@"共享给:%@",model.EnjoyUser];
- cell.selectBtn.selected = model.isSelect;
- [cell.selectBtn setAction:^{
- model.isSelect = !model.isSelect;
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView reloadRowAtIndexPath:indexPath withRowAnimation:UITableViewRowAnimationNone];
- });
- }];
- return cell;
- }
- break;
- }
-
- }
- break;
- }
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(nonnull NSIndexPath *)indexPath
- {
- [tableView deselectRowAtIndexPath:indexPath animated:YES];
- MyTDTSEModel * model = [self.dataArray objectAtIndex:indexPath.row];
- switch (self.operationStateEnum) {
- case OperationStateEnum1:{
- NSLog(@"编辑状态的cell");
- model.isSelect = !model.isSelect;
- [tableView reloadRowAtIndexPath:indexPath withRowAnimation:UITableViewRowAnimationNone];
- }break;
- default:{
- NSLog(@"正常状态的cell");
- NSDictionary * dict = @{@"Id":@(model.Id),@"Name":model.Name};
- [[NSNotificationCenter defaultCenter] postNotificationName:SELECTEXTENTSUCCESS object:nil userInfo:dict];
- [self backViewController];
- }break;
- }
- }
- -(void)backViewController
- {
- for ( int i = 0 ;i< self.navigationController.viewControllers.count;i++) {
- if ([self.navigationController.viewControllers[i] isKindOfClass:NSClassFromString(@"MyTDTopicCreateVC")]) {
- [self.navigationController popToViewController:self.navigationController.viewControllers[i] animated:YES];
- return;
- }
- }
- }
- - (NSMutableArray *)dataArray
- {
- if (!_dataArray) {
- _dataArray = [NSMutableArray array];
- }
- return _dataArray;
- }
- @end
|