Files
xj-ios/XinjiangProject/XinjiangProject/Project/Qusetion/View/HealthyQuestionTable.m
T
2026-02-05 20:24:38 +08:00

149 lines
3.7 KiB
Objective-C

//
// HealthyQuestionTable.m
// XinjiangProject
//
// Created by 仁康信息 on 2023/4/14.
//
#import "HealthyQuestionTable.h"
#import "HealthyDoctorTableViewCell.h"
#import "QustionHomeRecordsCell.h"
@interface HealthyQuestionTable ()<UITableViewDelegate,UITableViewDataSource>
@end
@implementation HealthyQuestionTable
- (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(45);
}
- (CGFloat )tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
return CGFLOAT_MIN;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
UIView * sectionHeardView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kRealValue(45))];
sectionHeardView.backgroundColor = CViewBgColor;
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];
YYLabel * morelabel = [[YYLabel alloc] initWithFrame:CGRectMake(kScreenWidth - 165 , kRealValue(17), 150, 15)];
morelabel.text = @"更多 >";
morelabel.textAlignment = NSTextAlignmentRight;
morelabel.textColor = UIColorHex(#999999);
morelabel.font = SYSTEMFONT(14);
MJWeakSelf
[morelabel setTextTapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
if (self.lookMoreBlock) {
self.lookMoreBlock();
}
}];
[sectionHeardView addSubview:morelabel];
return sectionHeardView;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
return [[UIView alloc] init];
}
@end