165 lines
4.3 KiB
Objective-C
165 lines
4.3 KiB
Objective-C
//
|
|
// XJHomePageV2QuestionTableView.m
|
|
// XinjiangProject
|
|
//
|
|
// Created by Apple on 2026/2/9.
|
|
//
|
|
|
|
#import "XJHomePageV2QuestionTableView.h"
|
|
#import "HealthyQuestionTable.h"
|
|
#import "HealthyDoctorTableViewCell.h"
|
|
#import "QustionHomeRecordsCell.h"
|
|
|
|
@interface XJHomePageV2QuestionTableView ()<UITableViewDelegate,UITableViewDataSource>
|
|
|
|
@end
|
|
|
|
@implementation XJHomePageV2QuestionTableView
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style
|
|
{
|
|
if (self = [super initWithFrame:frame style:style])
|
|
{
|
|
[self createUI];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
|
|
- (void)createUI
|
|
{
|
|
if (@available(iOS 11.0, *)) {
|
|
self.estimatedRowHeight = 0;
|
|
self.estimatedSectionFooterHeight = 0;
|
|
self.estimatedSectionHeaderHeight = 0;
|
|
self.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
|
}
|
|
self.delegate = self;
|
|
self.dataSource = self;
|
|
self.separatorStyle = UITableViewCellSeparatorStyleNone;
|
|
self.showsVerticalScrollIndicator = NO;
|
|
self.estimatedRowHeight = 60;
|
|
self.rowHeight = UITableViewAutomaticDimension;
|
|
}
|
|
|
|
- (void)setDataArray:(NSArray *)dataArray
|
|
{
|
|
_dataArray = dataArray;
|
|
[self reloadData];
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - DataSource
|
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
|
{
|
|
|
|
return self.dataArray.count;
|
|
}
|
|
|
|
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
|
|
{
|
|
return 1;
|
|
|
|
}
|
|
|
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
|
|
|
|
|
static NSString * cellID = @"cellID";
|
|
|
|
|
|
QustionHomeRecordsCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
|
|
|
|
if (!cell) {
|
|
|
|
cell = [[QustionHomeRecordsCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
|
|
}
|
|
cell.model = self.dataArray[indexPath.row];
|
|
cell.backgroundColor = CViewBgColor;
|
|
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
|
return cell;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
|
{
|
|
HomeQusetionRecordsModel * model = self.dataArray[indexPath.row];
|
|
|
|
if (self.tableBlock) {
|
|
|
|
self.tableBlock(model);
|
|
}
|
|
|
|
}
|
|
|
|
- (CGFloat )tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
|
|
{
|
|
return kRealValue(40);
|
|
}
|
|
|
|
- (CGFloat )tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
|
|
{
|
|
return CGFLOAT_MIN;
|
|
}
|
|
|
|
|
|
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
|
|
|
|
UIView * sectionHeardView = [[UIView alloc] initWithFrame:CGRectMake(12, 0, kScreenWidth -24, kRealValue(40))];
|
|
sectionHeardView.backgroundColor = CViewBgColor;
|
|
|
|
UIImageView * heaedImg = [[UIImageView alloc] init];
|
|
heaedImg.image = [UIImage imageNamed:@"heaedTitleBackImg"];
|
|
[sectionHeardView addSubview:heaedImg];
|
|
|
|
[heaedImg mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.edges.mas_offset(0);
|
|
}];
|
|
|
|
|
|
UILabel * todayLabel = [[UILabel alloc] initWithFrame:CGRectMake(kRealValue(15), kRealValue(16), 190, 16)];
|
|
|
|
todayLabel.text = @"专家咨询记录";
|
|
|
|
todayLabel.textAlignment = NSTextAlignmentLeft;
|
|
|
|
todayLabel.textColor = CFontColor1;
|
|
|
|
todayLabel.font = BOLDSYSTEMFONT(16);
|
|
|
|
[sectionHeardView addSubview:todayLabel];
|
|
|
|
[todayLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_offset(13);
|
|
make.top.bottom.mas_offset(0);
|
|
}];
|
|
|
|
UIButton * moreBtn = [[UIButton alloc] init];
|
|
[moreBtn setImage:[UIImage imageNamed:@"wacthRightAccow"] forState:UIControlStateNormal];
|
|
[moreBtn addTarget:self action:@selector(moreClick) forControlEvents:UIControlEventTouchUpInside];
|
|
[sectionHeardView addSubview:moreBtn];
|
|
[moreBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.right.mas_offset(-8);
|
|
make.centerY.mas_equalTo(sectionHeardView);
|
|
make.width.height.mas_offset(30);
|
|
}];
|
|
return sectionHeardView;
|
|
|
|
}
|
|
- (void)moreClick {
|
|
|
|
if (self.lookMoreBlock) {
|
|
self.lookMoreBlock();
|
|
}
|
|
|
|
}
|
|
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
|
|
|
|
return [[UIView alloc] init];
|
|
}
|
|
@end
|