12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- //
- // RDSSelectDeviceSubVC.m
- // Temperature
- //
- // Created by 姓二名哈字富贵儿 on 2023/8/17.
- //
- #import "RDSSelectDeviceSubVC.h"
- #import "RDSDeviceTypeCell.h"
- @interface RDSSelectDeviceSubVC () <UITableViewDelegate, UITableViewDataSource>
- @property (nonatomic, strong) UITableView *tableView;
- @property (nonatomic, strong) NSArray *dataSource;
- @end
- @implementation RDSSelectDeviceSubVC
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self configSubviews];
- }
- - (void)configSubviews {
- self.tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
- self.tableView.backgroundColor = [UIColor colorWithHexString:@"#FBFBFB"];
- self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- self.tableView.delegate = self;
- self.tableView.dataSource = self;
- [self.tableView registerClass:[RDSDeviceTypeCell class] forCellReuseIdentifier:NSStringFromClass([RDSDeviceTypeCell class])];
- [self.view addSubview:self.tableView];
- [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.bottom.equalTo(self.view);
- make.top.equalTo(self.view.mas_safeAreaLayoutGuideTop);
- }];
- }
- - (void)reloadDataWithDataSource:(NSArray *)dataSource {
- if (!dataSource) {
- self.dataSource = [NSArray array];
- } else {
- self.dataSource = [dataSource copy];
- }
- [self.tableView reloadData];
- }
- #pragma mark - UITableViewDataSource
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
- return self.dataSource.count;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- return 1;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- RDSDeviceTypeCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([RDSDeviceTypeCell class]) forIndexPath:indexPath];
- cell.deviceTypeModel = self.dataSource[indexPath.section];
- return cell;
- }
- - (NSArray *)dataSource {
- if (!_dataSource) {
- _dataSource = [NSArray array];
- }
- return _dataSource;
- }
- @end
|