// // PBScrollModelView.m // IphoneBIMe // // Created by ZhangJF on 2022/10/20. // Copyright © 2022 ProBIM. All rights reserved. // #import "PBScrollModelView.h" #import "PBModelsModel.h" static NSString *const CellID = @"CellID"; @interface PBScrollModelView() @property (nonatomic, strong) UITableView *tableView; @end @implementation PBScrollModelView - (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.modelArr.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellID forIndexPath:indexPath]; PBModelsModel *model = self.modelArr[indexPath.row]; cell.textLabel.text = model.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.modelArr[indexPath.row]); } } - (void)setModelArr:(NSArray *)modelArr { _modelArr = modelArr; [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