97 lines
4.1 KiB
Objective-C
97 lines
4.1 KiB
Objective-C
//
|
||
// HomeRankContentVC.m
|
||
// keyBoard
|
||
//
|
||
// Created by Mac on 2025/11/6.
|
||
//
|
||
|
||
#import "HomeRankContentVC.h"
|
||
#import "HomeHotCell.h"
|
||
@interface HomeRankContentVC () <UITableViewDataSource, UITableViewDelegate>
|
||
@property (nonatomic, strong) NSArray<NSDictionary *> *dataSource; // 简单模拟数据
|
||
|
||
@end
|
||
|
||
@implementation HomeRankContentVC
|
||
|
||
- (void)viewDidLoad {
|
||
[super viewDidLoad];
|
||
// Do any additional setup after loading the view.
|
||
// 构建数据(演示)
|
||
self.dataSource = @[
|
||
@{@"rank":@4, @"title":@"Ambiguous", @"sub":@"Be Neither Too Close Nor Too Distant, Want To ...", @"joined":@NO},
|
||
@{@"rank":@5, @"title":@"Ambiguous", @"sub":@"Be Neither Too Close Nor Too Distant, Want To ...", @"joined":@YES},
|
||
@{@"rank":@6, @"title":@"Ambiguous", @"sub":@"Be Neither Too Close Nor Too Distant, Want To ...", @"joined":@NO},
|
||
@{@"rank":@7, @"title":@"Ambiguous", @"sub":@"Be Neither Too Close Nor Too Distant, Want To ...", @"joined":@NO},
|
||
@{@"rank":@4, @"title":@"Ambiguous", @"sub":@"Be Neither Too Close Nor Too Distant, Want To ...", @"joined":@NO},
|
||
@{@"rank":@5, @"title":@"Ambiguous", @"sub":@"Be Neither Too Close Nor Too Distant, Want To ...", @"joined":@YES},
|
||
@{@"rank":@6, @"title":@"Ambiguous", @"sub":@"Be Neither Too Close Nor Too Distant, Want To ...", @"joined":@NO},
|
||
@{@"rank":@7, @"title":@"Ambiguous", @"sub":@"Be Neither Too Close Nor Too Distant, Want To ...", @"joined":@NO},
|
||
@{@"rank":@4, @"title":@"Ambiguous", @"sub":@"Be Neither Too Close Nor Too Distant, Want To ...", @"joined":@NO},
|
||
@{@"rank":@5, @"title":@"Ambiguous", @"sub":@"Be Neither Too Close Nor Too Distant, Want To ...", @"joined":@YES},
|
||
@{@"rank":@6, @"title":@"Ambiguous", @"sub":@"Be Neither Too Close Nor Too Distant, Want To ...", @"joined":@NO},
|
||
@{@"rank":@7, @"title":@"Ambiguous", @"sub":@"Be Neither Too Close Nor Too Distant, Want To ...", @"joined":@NO}
|
||
];
|
||
// 设置背景颜色:随机色
|
||
self.view.backgroundColor = COLOR_WITH_RGB(arc4random()%255/255.0, arc4random()%255/255.0, arc4random()%255/255.0, 1);
|
||
[self.view addSubview:self.tableView];
|
||
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.top.right.equalTo(self.view);
|
||
make.bottom.equalTo(self.view);
|
||
|
||
}];
|
||
}
|
||
|
||
#pragma mark - UITableViewDataSource
|
||
|
||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||
return self.dataSource.count;
|
||
}
|
||
|
||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||
HomeHotCell *cell = [tableView dequeueReusableCellWithIdentifier:HomeHotCell.reuseId forIndexPath:indexPath];
|
||
NSDictionary *item = self.dataSource[indexPath.row];
|
||
// 配置 cell
|
||
[cell configWithRank:[item[@"rank"] integerValue]
|
||
title:item[@"title"]
|
||
subtitle:item[@"sub"]
|
||
joined:[item[@"joined"] boolValue]];
|
||
return cell;
|
||
}
|
||
|
||
#pragma mark - UITableViewDelegate
|
||
|
||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||
return 84.0;
|
||
}
|
||
|
||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
||
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
||
|
||
}
|
||
|
||
- (BaseTableView *)tableView {
|
||
if (!_tableView) {
|
||
// 使用 BaseTableView,统一默认配置
|
||
_tableView = [[BaseTableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
|
||
_tableView.dataSource = self;
|
||
_tableView.delegate = self;
|
||
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone; // 设计为卡片式,去掉系统分割线
|
||
_tableView.showsVerticalScrollIndicator = NO;
|
||
_tableView.contentInset = UIEdgeInsetsMake(8, 0, KB_SafeAreaBottom(), 0);
|
||
[_tableView registerClass:HomeHotCell.class forCellReuseIdentifier:HomeHotCell.reuseId];
|
||
}
|
||
return _tableView;
|
||
}
|
||
|
||
|
||
#pragma mark - JXCategoryListContentViewDelegate
|
||
|
||
/**
|
||
实现 <JXCategoryListContentViewDelegate> 协议方法,返回该视图控制器所拥有的「视图」
|
||
*/
|
||
- (UIView *)listView {
|
||
return self.view;
|
||
}
|
||
@end
|