Commit 427e365f authored by zhaowl123's avatar zhaowl123
Browse files

4.15.2

parent 03a5ae91
No preview for this file type
......@@ -284,6 +284,9 @@
04BDEECF2269C534006759A5 /* icon_arrow@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 04BDEECD2269C534006759A5 /* icon_arrow@3x.png */; };
04BDEED22269C5F0006759A5 /* icon_markplay@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 04BDEED02269C5EF006759A5 /* icon_markplay@2x.png */; };
04BDEED32269C5F0006759A5 /* icon_markplay@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 04BDEED12269C5F0006759A5 /* icon_markplay@3x.png */; };
04CA62FF271FBF63003F315D /* DWKnowledgeTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 04CA62FC271FBF63003F315D /* DWKnowledgeTableViewCell.m */; };
04CA6300271FBF63003F315D /* DWPlayerKnowledgeView.m in Sources */ = {isa = PBXBuildFile; fileRef = 04CA62FE271FBF63003F315D /* DWPlayerKnowledgeView.m */; };
04CA6303271FBF8E003F315D /* DWKnowledgeModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 04CA6302271FBF8E003F315D /* DWKnowledgeModel.m */; };
04CB7E6B24AD7E8800EF6BCF /* DWBarrageTextDescriptor.m in Sources */ = {isa = PBXBuildFile; fileRef = 04CB7E6024AD7E8800EF6BCF /* DWBarrageTextDescriptor.m */; };
04CB7E6C24AD7E8800EF6BCF /* DWBarrageSegmentView.m in Sources */ = {isa = PBXBuildFile; fileRef = 04CB7E6124AD7E8800EF6BCF /* DWBarrageSegmentView.m */; };
04CB7E6D24AD7E8800EF6BCF /* DWBarrageInputView.m in Sources */ = {isa = PBXBuildFile; fileRef = 04CB7E6224AD7E8800EF6BCF /* DWBarrageInputView.m */; };
......@@ -836,6 +839,12 @@
04BDEECD2269C534006759A5 /* icon_arrow@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon_arrow@3x.png"; sourceTree = "<group>"; };
04BDEED02269C5EF006759A5 /* icon_markplay@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon_markplay@2x.png"; sourceTree = "<group>"; };
04BDEED12269C5F0006759A5 /* icon_markplay@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon_markplay@3x.png"; sourceTree = "<group>"; };
04CA62FB271FBF63003F315D /* DWKnowledgeTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DWKnowledgeTableViewCell.h; sourceTree = "<group>"; };
04CA62FC271FBF63003F315D /* DWKnowledgeTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DWKnowledgeTableViewCell.m; sourceTree = "<group>"; };
04CA62FD271FBF63003F315D /* DWPlayerKnowledgeView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DWPlayerKnowledgeView.h; sourceTree = "<group>"; };
04CA62FE271FBF63003F315D /* DWPlayerKnowledgeView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DWPlayerKnowledgeView.m; sourceTree = "<group>"; };
04CA6301271FBF8E003F315D /* DWKnowledgeModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DWKnowledgeModel.h; sourceTree = "<group>"; };
04CA6302271FBF8E003F315D /* DWKnowledgeModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DWKnowledgeModel.m; sourceTree = "<group>"; };
04CB7E5F24AD7E8800EF6BCF /* DWBarrageBgView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DWBarrageBgView.h; sourceTree = "<group>"; };
04CB7E6024AD7E8800EF6BCF /* DWBarrageTextDescriptor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DWBarrageTextDescriptor.m; sourceTree = "<group>"; };
04CB7E6124AD7E8800EF6BCF /* DWBarrageSegmentView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DWBarrageSegmentView.m; sourceTree = "<group>"; };
......@@ -1103,6 +1112,8 @@
0434421A225F1139003F7EC1 /* Model */ = {
isa = PBXGroup;
children = (
04CA6301271FBF8E003F315D /* DWKnowledgeModel.h */,
04CA6302271FBF8E003F315D /* DWKnowledgeModel.m */,
04FFA9AC226426E0008C2713 /* DWVodModel.h */,
04FFA9AD226426E0008C2713 /* DWVodModel.m */,
0412FA8F2266D0D800D8E6C1 /* DWTableChooseModel.h */,
......@@ -1275,6 +1286,10 @@
04357C6422699371002081C0 /* Player */ = {
isa = PBXGroup;
children = (
04CA62FB271FBF63003F315D /* DWKnowledgeTableViewCell.h */,
04CA62FC271FBF63003F315D /* DWKnowledgeTableViewCell.m */,
04CA62FD271FBF63003F315D /* DWPlayerKnowledgeView.h */,
04CA62FE271FBF63003F315D /* DWPlayerKnowledgeView.m */,
04E789EA2696EDC500A1C6D4 /* DWVodPlayerView.h */,
04E789E92696EDC400A1C6D4 /* DWVodPlayerView.m */,
04FFA9AF22642E7D008C2713 /* DWVodPlayTableViewCell.h */,
......@@ -2271,7 +2286,9 @@
04344367225F1F07003F7EC1 /* UIImage+ForceDecode.m in Sources */,
04D596112272AFE400EE618C /* DWDownloadManagerViewController.m in Sources */,
04EB65BF226D679F00FAB532 /* DWSettingFuncButton.m in Sources */,
04CA6303271FBF8E003F315D /* DWKnowledgeModel.m in Sources */,
0434437A225F1F07003F7EC1 /* SDAnimatedImageRep.m in Sources */,
04CA6300271FBF63003F315D /* DWPlayerKnowledgeView.m in Sources */,
049FF17C225EEEA700D944C5 /* DWToastView.m in Sources */,
04CB7E8724AD81BC00EF6BCF /* OCBarrageDescriptor.m in Sources */,
04344385225F1F07003F7EC1 /* SDImageFrame.m in Sources */,
......@@ -2379,6 +2396,7 @@
04344386225F1F07003F7EC1 /* SDWebImageDownloaderOperation.m in Sources */,
04344377225F1F07003F7EC1 /* MKAnnotationView+WebCache.m in Sources */,
049FF09B225EEEA700D944C5 /* NSString+MJExtension.m in Sources */,
04CA62FF271FBF63003F315D /* DWKnowledgeTableViewCell.m in Sources */,
049FF097225EEEA700D944C5 /* NSObject+MJCoding.m in Sources */,
049FF17A225EEEA700D944C5 /* DWAdShouView.m in Sources */,
04344380225F1F07003F7EC1 /* NSBezierPath+RoundedCorners.m in Sources */,
......
......@@ -206,6 +206,7 @@
DWVodPlayViewController * vodPlayVC = [[DWVodPlayViewController alloc]init];
vodPlayVC.vodModel = vodModel;
vodPlayVC.vidoeList = self.videoList;
vodPlayVC.index = indexPath.row;
[self.navigationController pushViewController:vodPlayVC animated:YES];
}
......
......@@ -16,6 +16,7 @@ NS_ASSUME_NONNULL_BEGIN
@property(nonatomic,strong)NSArray * vidoeList;//选集列表
@property(nonatomic,assign)BOOL landScape;//是否横屏
@property (nonatomic, assign) NSInteger index;//判断播放的事第几个视频 只有播放第一个视频的时候才会有知识点功能
@end
......
......@@ -618,7 +618,7 @@ typedef enum : NSUInteger {
CGFloat a = [[UIApplication sharedApplication] delegate].window.safeAreaInsets.bottom;
if (a > 0) {
viewSize = CGSizeMake(ScreenWidth, ScaleHeight(ScreenWidth, 375 / 211.0) + 64);
}else{
}else{
viewSize = CGSizeMake(ScreenWidth, ScaleHeight(ScreenWidth, 375 / 211.0));
}
} else {
......@@ -632,7 +632,24 @@ typedef enum : NSUInteger {
self.playerView.selectionList = self.vidoeList;
[self.playerView quitWindowsModel];
}else{
self.playerView = [[DWVodPlayerView alloc]init];
NSDictionary *dict = @{@"title":@"知识点",
@"pauseStatus":@(1),
@"category":@[
@{@"cateId":@"1", @"name":@"获得发展史", @"info":@[@{@"id":@"1", @"startTime":@"17",@"endTime":@"35", @"desc":@"发展史"}]}, @{@"cateId":@"2", @"name":@"品牌升级", @"info":@[@{@"id":@"1", @"startTime":@"35", @"endTime":@"50", @"desc":@"品牌升级"}]},
@{@"cateId":@"3", @"name":@"产品介绍", @"info":@[@{@"id":@"1", @"startTime":@"50", @"endTime":@"63", @"desc":@"产品介绍"}, @{@"id":@"2", @"startTime":@"64", @"endTime":@"68",@"desc":@"数说获得"},@{@"id":@"3", @"startTime":@"68", @"endTime":@"83",@"desc":@"应用场景"}]},
@{@"cateId":@"4", @"name":@"领导风采", @"info":@[@{@"id":@"1", @"startTime":@"84", @"endTime":@"96", @"desc":@"CEO"},@{@"id":@"2", @"startTime":@"223", @"endTime":@"265", @"desc":@"CEO"}]},
@{@"cateId":@"5", @"name":@"客户案例", @"info":@[@{@"id":@"1", @"startTime":@"100", @"endTime":@"108", @"desc":@"北京四中网校"},@{@"id":@"2", @"startTime":@"108", @"endTime":@"112", @"desc":@"环球优学"}, @{@"id":@"3", @"startTime":@"112", @"endTime":@"120", @"desc":@"结构思考力学院"},@{@"id":@"4", @"startTime":@"121", @"endTime":@"130", @"desc":@"馒头商学院"},@{@"id":@"5", @"startTime":@"130", @"endTime":@"138", @"desc":@"点掌财经"}, @{@"id":@"6", @"startTime":@"139", @"endTime":@"146", @"desc":@"云朵课堂"}]},
@{@"cateId":@"6", @"name":@"员工风采", @"info":@[@{@"id":@"1", @"startTime":@"148", @"endTime":@"208", @"desc":@"员工风采锦集"}]}
]
};
// NSError *error;
// NSString *path = [[NSBundle mainBundle]pathForResource:@"knowledge" ofType:@"json"];
// NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOfFile:path] options:NSJSONReadingMutableLeaves error:&error];
if(self.index == 0){//传入知识点功能的数据
self.playerView = [[DWVodPlayerView alloc]initWithKnowledgeData:dict];
}else{
self.playerView = [[DWVodPlayerView alloc] init];
}
//选集
self.playerView.selectionList = self.vidoeList;
}
......
//
// DWKnowledgeModel.h
// Demo
//
// Created by gw on 2021/10/12.
// Copyright © 2021 com.bokecc.www. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@class info;
@interface DWKnowledgeModel : NSObject
@property (nonatomic, copy) NSString *cateId;
@property (nonatomic, copy) NSString *name;
@property (nonatomic, copy) NSMutableArray <info *>*info;
@property (nonatomic, assign) BOOL isSelect;//默认为NO
@end
@interface info : NSObject
@property (nonatomic, copy) NSString *id;
@property (nonatomic, copy) NSString *startTime;
@property (nonatomic, copy) NSString *endTime;
@property (nonatomic, copy) NSString *desc;
@end
NS_ASSUME_NONNULL_END
//
// DWKnowledgeModel.m
// Demo
//
// Created by gw on 2021/10/12.
// Copyright © 2021 com.bokecc.www. All rights reserved.
//
#import "DWKnowledgeModel.h"
@implementation DWKnowledgeModel
+ (NSDictionary *)objectClassInArray{
return @{@"info" : [info class]};
}
@end
@implementation info
@end
//
// DWKnowledgeTableViewCell.h
// Demo
//
// Created by gw on 2021/10/12.
// Copyright © 2021 com.bokecc.www. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "DWKnowledgeModel.h"
NS_ASSUME_NONNULL_BEGIN
@interface DWKnowledgeTableViewCell : UITableViewCell
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *decLabel;
@property (nonatomic, strong) UILabel *circleLabel;
@property (nonatomic, strong) UIView *topView;
@property (nonatomic, strong) UIView *bottomView;
- (void)configViewWithModel:(info *)model;
@end
NS_ASSUME_NONNULL_END
//
// DWKnowledgeTableViewCell.m
// Demo
//
// Created by gw on 2021/10/12.
// Copyright © 2021 com.bokecc.www. All rights reserved.
//
#import "DWKnowledgeTableViewCell.h"
@implementation DWKnowledgeTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
self.selectionStyle = UITableViewCellSelectionStyleNone;
self.backgroundColor = UIColor.clearColor;
_circleLabel = [UILabel new];
_circleLabel.layer.cornerRadius = 13;
_circleLabel.layer.masksToBounds = YES;
_circleLabel.layer.borderWidth = 1;
_circleLabel.layer.borderColor = UIColor.whiteColor.CGColor;
_circleLabel.textAlignment = 1;
_circleLabel.textColor = ColorFrom16A(0xffffff, 0.7);
[self addSubview:_circleLabel];
[_circleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(self.mas_centerY);
make.left.equalTo(self).offset(15);
make.width.and.height.equalTo(@26);
}];
_topView = [UIView new];
_topView.backgroundColor = UIColor.whiteColor;
[self addSubview:_topView];
[_topView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self);
make.bottom.equalTo(_circleLabel.mas_top);
make.width.equalTo(@1);
make.centerX.equalTo(_circleLabel.mas_centerX);
}];
_bottomView = [UIView new];
_bottomView.backgroundColor = UIColor.whiteColor;
[self addSubview:_bottomView];
[_bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(_circleLabel.mas_bottom);
make.bottom.equalTo(self);
make.width.equalTo(@1);
make.centerX.equalTo(_circleLabel.mas_centerX);
}];
_titleLabel = [UILabel new];
_titleLabel.textColor = ColorFrom16A(0xffffff, 0.8);
_titleLabel.font = TitleFont(15);
[self addSubview:_titleLabel];
[_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self).offset(10);
make.left.equalTo(_circleLabel.mas_right).offset(10);
make.right.equalTo(self).offset(-10);
make.height.equalTo(@15);
}];
_decLabel = [UILabel new];
_decLabel.textColor = ColorFrom16A(0xffffff, 0.8);
_decLabel.font = TitleFont(14);
[self addSubview:_decLabel];
[_decLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(_titleLabel.mas_bottom).offset(11);
make.left.equalTo(_titleLabel);
make.right.equalTo(_titleLabel);
make.height.equalTo(@14);
}];
}
return self;
}
- (void)configViewWithModel:(info *)model{
_circleLabel.text = model.id;
if(model.desc.length == 0){
_decLabel.hidden = YES;
[_titleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(self.mas_centerY);
make.left.equalTo(_circleLabel.mas_right).offset(10);
make.right.equalTo(self).offset(-10);
make.height.equalTo(@15);
}];
}else{
[_titleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self).offset(10);
make.left.equalTo(_circleLabel.mas_right).offset(10);
make.right.equalTo(self).offset(-10);
make.height.equalTo(@15);
}];
}
if(model.endTime.length == 0){
_titleLabel.text = [self getMMSSFromSS:model.startTime];
}else{
_titleLabel.text = [NSString stringWithFormat:@"%@~%@", [self getMMSSFromSS:model.startTime], [self getMMSSFromSS:model.endTime]];
}
_decLabel.text = model.desc;
}
//传入 秒 得到 xx分钟xx秒
-(NSString *)getMMSSFromSS:(NSString *)totalTime{
NSInteger seconds = [totalTime integerValue];
//format of minute
NSString *str_minute = [NSString stringWithFormat:@"%ld",seconds/60];
//format of second
NSString *str_second = [NSString stringWithFormat:@"%ld",seconds%60];
//format of time
if(str_minute.length <= 1){
str_minute = [NSString stringWithFormat:@"0%@", str_minute];
}
if(str_second.length <= 1){
str_second = [NSString stringWithFormat:@"0%@", str_second];
}
NSString *format_time = [NSString stringWithFormat:@"%@:%@",str_minute,str_second];
NSLog(@"format_time : %@",format_time);
return format_time;
}
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
//
// DWPlayerKnowledgeView.h
// Demo
//
// Created by gw on 2021/10/12.
// Copyright © 2021 com.bokecc.www. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "DWKnowledgeModel.h"
NS_ASSUME_NONNULL_BEGIN
typedef void(^DWKnowledgeDidselectBlcok)(info *model, BOOL pauseStatus, NSIndexPath *indexPath);//pauseStatus 1需要暂停 0不需要
@interface DWPlayerKnowledgeView : UIView
- (instancetype)initWithData:(NSDictionary *)knowledgeData totalTime:(CGFloat)totalTime index:(NSIndexPath *)indexPath;//totalTime当前视频的总时长
- (void)show;
- (void)dismiss;
@property (nonatomic, copy) DWKnowledgeDidselectBlcok knowledgeBlock;
@end
NS_ASSUME_NONNULL_END
//
// DWPlayerKnowledgeView.m
// Demo
//
// Created by gw on 2021/10/12.
// Copyright © 2021 com.bokecc.www. All rights reserved.
//
#import "DWPlayerKnowledgeView.h"
#import "DWKnowledgeModel.h"
#import "MJExtension.h"
#import "DWKnowledgeTableViewCell.h"
@interface DWPlayerKnowledgeView ()<UITableViewDelegate,UITableViewDataSource,UIGestureRecognizerDelegate>
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) UIView *bgView;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) NSMutableArray *datasource;
@property (nonatomic, copy) NSString *titleString;
@property (nonatomic, strong) NSIndexPath *indexPath;
@property (nonatomic, assign) BOOL pauseStatus;
@property (nonatomic, assign) CGFloat totalTime;
@end
@implementation DWPlayerKnowledgeView
- (instancetype)initWithData:(NSDictionary *)knowledgeData totalTime:(CGFloat)totalTime index:(nonnull NSIndexPath *)indexPath{
if(self = [super init]){
_indexPath = indexPath;
_totalTime = totalTime;
self.frame = CGRectMake(0, 0, ScreenWidth, ScreenHeight);
self.backgroundColor = [UIColor clearColor];
self.hidden = YES;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismiss)];
tap.delegate = self;
[self addGestureRecognizer:tap];
[[UIApplication sharedApplication].keyWindow addSubview:self];
_titleString = knowledgeData[@"title"];
_pauseStatus = [knowledgeData[@"pauseStatus"] boolValue];
[self setupUI];
NSArray *arr = knowledgeData[@"category"];
if(arr.count > 0){
for (NSDictionary *dict in arr) {
DWKnowledgeModel *model = [DWKnowledgeModel mj_objectWithKeyValues:dict];
if(model.info.count == 1){
model.isSelect = 1;
}else{
model.isSelect = 0;
}
[self.datasource addObject:model];
}
[self.tableView reloadData];
}
}
return self;
}
- (void)setupUI{
_bgView = [[UIView alloc] initWithFrame:CGRectMake(ScreenWidth, 0, ScreenWidth / 3, ScreenHeight)];
_bgView.backgroundColor = ColorFrom16A(0x151515, 0.8);
[self addSubview:_bgView];
_titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 14, 100, 14)];
_titleLabel.text = _titleString;
_titleLabel.textColor = UIColor.whiteColor;
_titleLabel.font = TitleFont(14);
[_bgView addSubview:_titleLabel];
UIButton *closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[closeBtn setImage:[UIImage imageNamed:@"knowledge_close"] forState:0];
[closeBtn addTarget:self action:@selector(dismiss) forControlEvents:UIControlEventTouchUpInside];
closeBtn.frame = CGRectMake(_bgView.frame.size.width - 50, 0, 40, 40);
[_bgView addSubview:closeBtn];
_tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 40, _bgView.frame.size.width, _bgView.frame.size.height - 40) style:UITableViewStylePlain];
_tableView.backgroundColor = UIColor.clearColor;
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.sectionHeaderHeight = 40;
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
[_tableView registerClass:[DWKnowledgeTableViewCell class] forCellReuseIdentifier:@"cell"];
[_bgView addSubview:_tableView];
}
- (void)show{
self.hidden = NO;
[UIView animateWithDuration:0.3 animations:^{
_bgView.frame = CGRectMake(ScreenWidth - ScreenWidth / 3, 0, ScreenWidth / 3, ScreenHeight);
}];
}
- (void)dismiss{
[UIView animateWithDuration:0.3 animations:^{
_bgView.frame = CGRectMake(ScreenWidth, 0, ScreenWidth / 3, ScreenHeight);
} completion:^(BOOL finished) {
self.hidden = YES;
}];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return self.datasource.count;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
DWKnowledgeModel *model = self.datasource[section];
UIView *headerView = [[UIView alloc] init];
headerView.backgroundColor = ColorFrom16A(0x151515, 1);
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 12.5, 150, 16)];
titleLabel.font = TitleFont(15);
titleLabel.textColor = UIColor.whiteColor;
titleLabel.text = [NSString stringWithFormat:@"%@(%ld)", model.name,model.info.count];
[headerView addSubview:titleLabel];
headerView.tag = section;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleHeaderViewAction:)];
UIImageView *iv = [[UIImageView alloc] initWithFrame:CGRectMake(_bgView.frame.size.width - 50, 0, 40, 40)];
if(model.isSelect){
iv.image = [UIImage imageNamed:@"knowledge_up"];
}else{
iv.image = [UIImage imageNamed:@"knowledge_down"];
}
if(self.datasource.count == 1 || model.info.count == 1){
iv.hidden = YES;
}else{
[headerView addGestureRecognizer:tap];
iv.hidden = NO;
}
[headerView addSubview:iv];
return headerView;
}
- (void)handleHeaderViewAction:(UITapGestureRecognizer *)tap{
NSInteger index = tap.view.tag;
DWKnowledgeModel *model = self.datasource[index];
if(model.isSelect == 0){
DWKnowledgeModel *replaceModel = self.datasource[index];
replaceModel.isSelect = 1;
[self.datasource replaceObjectAtIndex:index withObject:replaceModel];
}else{
DWKnowledgeModel *replaceModel = self.datasource[index];
replaceModel.isSelect = 0;
[self.datasource replaceObjectAtIndex:index withObject:replaceModel];
}
[self.tableView reloadData];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
DWKnowledgeModel *model = self.datasource[section];
if(self.datasource.count == 1){//当只有一个的时候要展开
return model.info.count;
}
if(model.isSelect == 0){
return 0;
}else{
return model.info.count;
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
DWKnowledgeModel *model = self.datasource[indexPath.section];
info *infoModel = model.info[indexPath.row];
if(infoModel.startTime.floatValue > _totalTime || infoModel.endTime.floatValue > _totalTime){
return 0;
}else{
return 60;
}
return 60;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
DWKnowledgeTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
DWKnowledgeModel *model = self.datasource[indexPath.section];
info *infoModel = model.info[indexPath.row];
[cell configViewWithModel:infoModel];
if(infoModel.startTime.floatValue > _totalTime || infoModel.endTime.floatValue > _totalTime){
cell.hidden = YES;
}else{
cell.hidden = NO;
}
if(model.info.count == 1){
cell.topView.hidden = YES;
cell.bottomView.hidden = YES;
}else{
cell.topView.hidden = NO;
cell.bottomView.hidden = NO;
}
if(indexPath.row == 0){
cell.topView.hidden = YES;
}else{
cell.topView.hidden = NO;
}
if(indexPath.row == model.info.count - 1){
cell.bottomView.hidden = YES;
}else{
cell.bottomView.hidden = NO;
}
if(_indexPath == indexPath){
cell.backgroundColor = ColorFrom16A(0xffffff, 0.1);
cell.circleLabel.backgroundColor = UIColor.whiteColor;
cell.circleLabel.font = [UIFont boldSystemFontOfSize:14];
cell.circleLabel.textColor = ColorFrom16A(0x333333, 1);
cell.titleLabel.textColor = UIColor.whiteColor;
cell.titleLabel.font = [UIFont boldSystemFontOfSize:15];
cell.decLabel.font = [UIFont boldSystemFontOfSize:14];
cell.decLabel.textColor = UIColor.whiteColor;