Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
陈高翔
/
DreamSleep-iOS
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit a315aea6
由
cgx
编写于
2022-06-22 09:21:03 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
优化首页助眠音乐出现无法显示bug
1 个父辈
45d5d79e
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
52 行增加
和
23 行删除
DreamSleep/DreamSleep/Class/HomeModule/Home/View/DSHomeView.m
DreamSleep/DreamSleep/Class/HomeModule/Home/View/DSHomeView.m
查看文件 @
a315aea
...
...
@@ -10,7 +10,12 @@
#import "GoodSleepSoundCell.h"
@interface
DSHomeView
()
<
UITableViewDelegate
,
UITableViewDataSource
>
/// 通用数据
@property
(
nonatomic
,
strong
)
NSArray
*
courseMusicArr
;
/// 舒眠课程数据
@property
(
nonatomic
,
strong
)
NSArray
*
courseListArr
;
/// 助眠音乐数据
@property
(
nonatomic
,
strong
)
NSArray
*
helpListArr
;
/// 类型数据
@property
(
nonatomic
,
strong
)
NSArray
*
typeArr
;
@end
...
...
@@ -25,8 +30,6 @@
self
.
showsVerticalScrollIndicator
=
NO
;
self
.
delegate
=
self
;
self
.
dataSource
=
self
;
[
self
registerClass
:[
CourseMusicCell
class
]
forCellReuseIdentifier
:
NSStringFromClass
([
CourseMusicCell
class
])];
[
self
registerClass
:[
GoodSleepSoundCell
class
]
forCellReuseIdentifier
:
NSStringFromClass
([
GoodSleepSoundCell
class
])];
self
.
tableHeaderView
=
self
.
headerView
;
}
return
self
;
...
...
@@ -37,40 +40,43 @@
}
-
(
void
)
updateCourseMusicCell
:
(
CellType
)
type
data
:
(
NSArray
*
)
dataArr
{
NSInteger
index
=
type
==
CellTypeCourse
?
0
:
1
;
CourseMusicCell
*
cell
=
(
CourseMusicCell
*
)[
self
cellForRowAtIndexPath
:[
NSIndexPath
indexPathForRow
:
index
inSection
:
0
]];
[
cell
updateCourseMusicListWithData
:
dataArr
cellIndex
:
index
];
if
(
dataArr
&&
dataArr
.
count
>
0
)
{
if
(
type
==
CellTypeCourse
)
{
self
.
courseListArr
=
dataArr
;
}
else
if
(
type
==
CellTypeMusic
)
{
self
.
helpListArr
=
dataArr
;
}
[
self
reloadData
];
}
}
-
(
void
)
updateNoiseAllTypeData
:
(
NSArray
*
)
typeDataArr
{
if
(
typeDataArr
&&
typeDataArr
.
count
>
0
)
{
self
.
typeArr
=
typeDataArr
;
}
GoodSleepSoundCell
*
cell
=
(
GoodSleepSoundCell
*
)[
self
cellForRowAtIndexPath
:[
NSIndexPath
indexPathForRow
:
2
inSection
:
0
]];
if
(
cell
)
{
[
cell
updateNoiseAllTypeData
:
typeDataArr
];
}
}
-
(
NSString
*
)
cellIdentiferAtIndexPath
:
(
NSIndexPath
*
)
indexPath
{
SafeSleepModel
*
item
=
self
.
courseMusicArr
[
indexPath
.
row
];
if
(
item
.
type
==
CellTypeGood
)
{
return
NSStringFromClass
([
GoodSleepSoundCell
class
]);
}
else
{
return
NSStringFromClass
([
CourseMusicCell
class
]);
[
self
reloadData
];
}
}
#pragma mark - UITableViewDelegate && UITableViewDataSource
-
(
nonnull
UITableViewCell
*
)
tableView
:
(
nonnull
UITableView
*
)
tableView
cellForRowAtIndexPath
:
(
nonnull
NSIndexPath
*
)
indexPath
{
HomeBasicCell
*
cell
=
[
tableView
dequeueReusableCellWithIdentifier
:[
self
cellIdentiferAtIndexPath
:
indexPath
]
forIndexPath
:
indexPath
];
[
cell
configBasicData
:
self
.
courseMusicArr
[
indexPath
.
row
]
cellIndex
:
indexPath
.
row
];
NSString
*
cellID
=
[
NSString
stringWithFormat
:
@"cmg_%zd"
,
indexPath
.
row
];
if
(
indexPath
.
row
==
2
)
{
GoodSleepSoundCell
*
goodCell
=
(
GoodSleepSoundCell
*
)
cell
;
GoodSleepSoundCell
*
goodCell
=
[
tableView
dequeueReusableCellWithIdentifier
:
cellID
];
if
(
!
goodCell
)
{
goodCell
=
[[
GoodSleepSoundCell
alloc
]
initWithStyle
:
UITableViewCellStyleDefault
reuseIdentifier
:
cellID
];
}
[
goodCell
configBasicData
:
self
.
courseMusicArr
[
indexPath
.
row
]
cellIndex
:
indexPath
.
row
];
[
goodCell
updateNoiseAllTypeData
:
self
.
typeArr
];
return
goodCell
;
}
else
{
CourseMusicCell
*
cell
=
[
tableView
dequeueReusableCellWithIdentifier
:
cellID
];
if
(
!
cell
)
{
cell
=
[[
CourseMusicCell
alloc
]
initWithStyle
:
UITableViewCellStyleDefault
reuseIdentifier
:
cellID
];
}
[
cell
configBasicData
:
self
.
courseMusicArr
[
indexPath
.
row
]
cellIndex
:
indexPath
.
row
];
[
cell
updateCourseMusicListWithData
:(
indexPath
.
row
==
0
?
self
.
courseListArr
:
self
.
helpListArr
)
cellIndex
:
indexPath
.
row
];
return
cell
;
}
return
cell
;
}
-
(
NSInteger
)
tableView
:
(
UITableView
*
)
tableView
numberOfRowsInSection
:
(
NSInteger
)
section
{
...
...
@@ -105,6 +111,15 @@
return
[[
UIView
alloc
]
initWithFrame
:
CGRectMake
(
0
,
0
,
10
,
0
.
001
)];
}
-
(
NSString
*
)
cellIdentiferAtIndexPath
:
(
NSIndexPath
*
)
indexPath
{
SafeSleepModel
*
item
=
self
.
courseMusicArr
[
indexPath
.
row
];
if
(
item
.
type
==
CellTypeGood
)
{
return
NSStringFromClass
([
GoodSleepSoundCell
class
]);
}
else
{
return
NSStringFromClass
([
CourseMusicCell
class
]);
}
}
#pragma mark - lazy
-
(
HomeHeaderView
*
)
headerView
{
if
(
!
_headerView
)
{
...
...
@@ -126,6 +141,20 @@
return
_courseMusicArr
;
}
-
(
NSArray
*
)
courseListArr
{
if
(
!
_courseListArr
)
{
_courseListArr
=
[
NSArray
array
];
}
return
_courseListArr
;
}
-
(
NSArray
*
)
helpListArr
{
if
(
!
_helpListArr
)
{
_helpListArr
=
[
NSArray
array
];
}
return
_helpListArr
;
}
-
(
NSArray
*
)
typeArr
{
if
(
!
_typeArr
)
{
_typeArr
=
[
NSArray
array
];
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论