//
|
// PBScrollStageView.m
|
// IphoneBIMe
|
//
|
// Created by ZhangJF on 2022/10/20.
|
// Copyright © 2022 ProBIM. All rights reserved.
|
//
|
|
#import "PBScrollStageView.h"
|
|
static NSString *const CellID = @"CellID";
|
@interface PBScrollStageView()<UITableViewDelegate, UITableViewDataSource>
|
@property (nonatomic, strong) UITableView *tableView;
|
@end
|
@implementation PBScrollStageView
|
- (instancetype)initWithFrame:(CGRect)frame {
|
if (self = [super initWithFrame:frame]) {
|
[self setupUI];
|
}
|
return self;
|
}
|
- (void)setupUI {
|
self.backgroundColor = [UIColor whiteColor];
|
|
self.tableView = [[UITableView alloc] init];
|
self.tableView.backgroundColor = [UIColor whiteColor];
|
self.tableView.dataSource = self;
|
self.tableView.delegate = self;
|
self.tableView.bounces = NO;
|
self.tableView.rowHeight = 40.f;
|
self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
|
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:CellID];
|
[self addSubview:self.tableView];
|
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.left.right.bottom.equalTo(self);
|
}];
|
}
|
#pragma mark - UITableViewDataSource
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
return self.stageArr.count;
|
}
|
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellID forIndexPath:indexPath];
|
NSDictionary *dict = self.stageArr[indexPath.row];
|
cell.textLabel.text = [dict valueForKey:@"name"];
|
cell.textLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:13];
|
return cell;
|
}
|
#pragma mark - UITableViewDelegate
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
if (self.saveBlock) {
|
self.saveBlock(self.stageArr[indexPath.row]);
|
}
|
}
|
|
- (void)setStageArr:(NSArray *)stageArr {
|
_stageArr = stageArr;
|
[self.tableView reloadData];
|
}
|
/*
|
// Only override drawRect: if you perform custom drawing.
|
// An empty implementation adversely affects performance during animation.
|
- (void)drawRect:(CGRect)rect {
|
// Drawing code
|
}
|
*/
|
|
@end
|