12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- //
- // TDGroupLabelVC.m
- // smartRhino
- //
- // Created by niuzhen on 2020/5/8.
- // Copyright © 2020 tederen. All rights reserved.
- //
- #import "TDGroupLabelVC.h"
- #import "TDGroupLabelCell.h"
- #import "AddGroupLabelVC.h"
- @interface TDGroupLabelVC ()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>
- @property (weak, nonatomic) IBOutlet UICollectionView *collectionView;
- @property (weak, nonatomic) IBOutlet UIButton *setBtn;
- @property (strong, nonatomic) NSArray *dataArray;
- @end
- @implementation TDGroupLabelVC
- +(TDGroupLabelVC *)initTDGroupLabelVC{
- TDGroupLabelVC *controller = [StoryboardManager.shared.TDGroup instantiateViewControllerWithIdentifier:@"TDGroupLabelVC"];
- return controller;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.fd_prefersNavigationBarHidden = YES;
- self.collectionView.delegate = self;
- self.collectionView.dataSource = self;
- [self.collectionView setCollectionViewLayout:[[UICollectionViewFlowLayout alloc] init]];
- self.collectionView.showsVerticalScrollIndicator = NO;
- self.collectionView.showsHorizontalScrollIndicator = NO;
- self.collectionView.contentInset = UIEdgeInsetsMake(2, 30, 0, 24);
- [self.collectionView registerNib:[UINib nibWithNibName:@"TDGroupLabelCell" bundle:nil] forCellWithReuseIdentifier:@"TDGroupLabelCell"];
- self.collectionView.backgroundColor = [UIColor whiteColor];
- self.dataArray = [self.labelName componentsSeparatedByString:@","];
- WS(weakSelf);
- [self.setBtn setAction:^{
- AddGroupLabelVC * vc = [AddGroupLabelVC initAddGroupLabelVC];
- vc.array = weakSelf.dataArray;
- vc.Id = weakSelf.Id;
- vc.refreshDataBlock = ^(NSArray * _Nonnull array) {
- weakSelf.dataArray = array;
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.collectionView reloadData];
- });
- if (weakSelf.refreshBlock) {
- weakSelf.refreshBlock();
- }
- };
- [weakSelf presentViewController:vc animated:YES completion:^{
- }];
- }];
- }
- - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
- return 1;
- }
- - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
- return self.dataArray.count;
- }
- - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
- {
- return CGSizeMake((SCREEN_WIDTH - 63) * 0.5, 58.f);
- }
- - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section
- {
- return 7.f;
- }
- - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section
- {
- return 9.f;
- }
- - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
- TDGroupLabelCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TDGroupLabelCell" forIndexPath:indexPath];
- cell.titleL.text = self.dataArray[indexPath.item];
- cell.deleteBtn.hidden = YES;
- return cell;
- }
- @end
|