| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220 |
- //
- // uploadFileRecordBodyView.m
- // 隐私保护
- //
- // Created by xd h on 2023/11/15.
- //
- #import "uploadFileRecordBodyView.h"
- #import "uploadFileRecordCell.h"
- #import "UIScrollView+EmptyDataSet.h"
- #import "uploadFileDataModel.h"
- @interface uploadFileRecordBodyView ()<UITableViewDelegate,UITableViewDataSource,UIScrollViewDelegate,DZNEmptyDataSetSource, DZNEmptyDataSetDelegate>
- @property (nonatomic,strong) UIScrollView *bgScrollV;
- @end
- @implementation uploadFileRecordBodyView
- - (id)initWithFrame:(CGRect)frame{
- self = [super initWithFrame:frame];
-
- _selectIndex = 1;
- [self drawAnyView];
-
- return self;
- }
- - (void)drawAnyView{
- [self setBackgroundColor:[UIColor whiteColor]];
-
- NSInteger maxNum = 3;
-
- _bgScrollV = [[UIScrollView alloc] init];
- _bgScrollV.showsHorizontalScrollIndicator = NO;
- _bgScrollV.pagingEnabled = YES;
- _bgScrollV.delegate = self;
- [self addSubview:_bgScrollV];
-
- [_bgScrollV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.top.mas_equalTo(0);
- make.bottom.mas_equalTo(0);
- }];
-
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.15 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- mainBlock(^{
- CGRect frame = self->_bgScrollV.frame;
- self->_bgScrollV.contentSize = CGSizeMake(maxNum* SCREEN_W, frame.size.height);
-
- for (NSInteger i= 0; i<maxNum; i++) {
- UITableView *curTableview = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
- curTableview.delegate = self;
- curTableview.dataSource = self;
- curTableview.showsVerticalScrollIndicator = NO;
- curTableview.showsHorizontalScrollIndicator = NO;
- // _tableView.contentInset = UIEdgeInsetsMake(-H_STATE_BAR, 0, 0, 0);
- [curTableview setSeparatorStyle:(UITableViewCellSeparatorStyleNone)];
- [curTableview setSeparatorColor:[UIColor clearColor]];
- [curTableview setBackgroundColor:[UIColor clearColor]];
- [curTableview setTableFooterView:[UIView new]];
- [curTableview setBounces:YES];
- if (@available(iOS 15.0, *)) {
- curTableview.sectionHeaderTopPadding = 0;
- }
- [self->_bgScrollV addSubview:curTableview];
-
- curTableview.tag = 10 +i;
-
- //空数据引入第三方开源处理
- curTableview.emptyDataSetSource = self;
- curTableview.emptyDataSetDelegate = self;
-
- [curTableview mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(SCREEN_W * i);
- make.width.mas_equalTo(SCREEN_W);
- make.top.mas_equalTo(0);
- make.height.mas_equalTo(frame.size.height);
- }];
- }
- });
- });
-
-
- }
- #pragma mark - 列表委托
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
- return 1;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
-
- NSInteger tag = tableView.tag - 10;
-
- if(_allDataArr && tag <_allDataArr.count){
- NSMutableArray *curArr = _allDataArr[tag];
-
- return curArr.count;
- }
-
- return 0;
-
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
-
- NSInteger row = indexPath.row;
- static NSString *identifier = @"uploadFileRecordCell";
-
- uploadFileRecordCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- if (!cell){
- cell = [[uploadFileRecordCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
- [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
- [cell setBackgroundColor:[UIColor clearColor]];
- [cell setAccessoryType:(UITableViewCellAccessoryNone)];
- }
-
- NSInteger tag = tableView.tag - 10;
-
- if(_allDataArr && tag <_allDataArr.count){
- NSMutableArray *curArr = _allDataArr[tag];
-
- if(row < curArr.count){
- uploadFileDataModel *model = curArr[row];
- cell.curUploadFileDataModel = model;
- }
- }
-
- return cell;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- return 70;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
- [tableView deselectRowAtIndexPath:indexPath animated:YES];
-
- }
- //- (void)scrollViewDidScroll:(UIScrollView *)scrollView
- - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
- {
- if(_bgScrollV != scrollView) return;
-
- CGFloat x = scrollView.contentOffset.x;
- NSInteger index = (x+1)/SCREEN_W;
-
- index += 1;//因为头部是从1开始的
-
- //HLog(@"index:%ld",index);
- if(_didScrollFun){
- _didScrollFun(index);
- }
-
- }
- #pragma mark 空数据
- - (UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView {
-
- return [UIImage imageNamed:@"uploadFile_noData"];
- }
- - (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView {
- NSString *text = NSLocalizedString(@"File_upload_Record_no_data",nil);
-
- NSDictionary *attributes = @{NSFontAttributeName: [UIFont systemFontOfSize:16.0f],
- NSForegroundColorAttributeName: HW999999Color};
-
- return [[NSAttributedString alloc] initWithString:text attributes:attributes];
- }
- //调整图片位置
- - (CGFloat)verticalOffsetForEmptyDataSet:(UIScrollView *)scrollView {
- return -150;
- }
- - (void)setSelectIndex:(NSInteger)selectIndex
- {
- _selectIndex = selectIndex;
-
- CGPoint poit = _bgScrollV.contentOffset;
- poit.x = SCREEN_W * (selectIndex -1);
-
- [UIView animateWithDuration:0.2 animations:^{
- self->_bgScrollV.contentOffset = poit;
- }];
- }
- - (void)setAllDataArr:(NSMutableArray *)allDataArr
- {
- _allDataArr = allDataArr;
-
- //刷新数据
- [self reloadAllDataFun];
- }
- #pragma mark 熟悉全部数据
- - (void)reloadAllDataFun
- {
- mainBlock(^{
- NSArray *subViews = [self->_bgScrollV subviews];
-
- for (UITableView *tableView in subViews) {
- if([tableView isKindOfClass:[UITableView class]]){
- [tableView reloadData];
- }
- }
- });
-
- }
- @end
|