TABAnimated icon indicating copy to clipboard operation
TABAnimated copied to clipboard

请问如何配置 collectionView 具有多个 section,且同一 section 有多种 item 样式的骨架?

Open tisfeng opened this issue 3 years ago • 21 comments

作者你好,如图,整体实现是一个瀑布流 collectionView,上下 2 个 section,而下面一个section 有多种 item 样式,请问这种情况如何实现对应的骨架? 我认真看了 Readme 和 Documents , demo 里没有找到相应示例,源码 API 也看了,但是一头雾水,只能来向作者请教,可以给点提示方向吗? image

tisfeng avatar Apr 06 '21 06:04 tisfeng

可以详细跟我说明一下,你这个页面的结构,和实现方式,我再给你提供相关解决方案。

tigerAndBull avatar Apr 06 '21 06:04 tigerAndBull

如图上下 2 个 section,上面一个 section 就一种 item 样式,而下面一个 section 目前有两种样式,一种是简单的卡片样式,另一种卡片样式内部是一个 collectionView,卡片高度都是动态计算的。

瀑布流布局样式大体是用 CHTCollectionViewWaterfallLayout 实现的,内部做了一些自定义修改。

113666218-877f3180-96e1-11eb-8829-cceb1ea850da

tisfeng avatar Apr 06 '21 07:04 tisfeng

抛开具体页面的布局以及实现,其实我更关心的是目前该框架是否支持 多个 section,且 section 有多种 cell 样式 这类通用页面布局的骨架?我初略看了一下代码配置 cell 相关的 API,貌似没有找到。

tisfeng avatar Apr 06 '21 07:04 tisfeng

想要支持只是开放一个接口,问题只是在于你的需求是什么,骨架屏不关心你自己的实现是否多cell

发自我的iPhone

------------------ 原始邮件 ------------------ 发件人: Tisfeng @.> 发送时间: 2021年4月6日 15:33 收件人: tigerAndBull/TABAnimated @.> 抄送: tigerAndBull @.>, Comment @.> 主题: 回复:[tigerAndBull/TABAnimated] 请问如何配置 collectionView 具有多个 section,且同一 section 有多种 item 样式的骨架? (#142)

抛开具体页面的布局以及实现,其实我更关心的是目前该框架是否支持 多个 section,且 section 有多种 cell 样式 这类通用页面布局的骨架?我初略看了一下代码配置 cell 相关的 API,貌似没有找到。

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

tigerAndBull avatar Apr 06 '21 07:04 tigerAndBull

瀑布流需要绑定sel,以便切面管理

发自我的iPhone

------------------ 原始邮件 ------------------ 发件人: Tisfeng @.> 发送时间: 2021年4月6日 15:33 收件人: tigerAndBull/TABAnimated @.> 抄送: tigerAndBull @.>, Comment @.> 主题: 回复:[tigerAndBull/TABAnimated] 请问如何配置 collectionView 具有多个 section,且同一 section 有多种 item 样式的骨架? (#142)

抛开具体页面的布局以及实现,其实我更关心的是目前该框架是否支持 多个 section,且 section 有多种 cell 样式 这类通用页面布局的骨架?我初略看了一下代码配置 cell 相关的 API,貌似没有找到。

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

tigerAndBull avatar Apr 06 '21 07:04 tigerAndBull

#pragma mark - 瀑布流

+ (instancetype)animatedWaterFallLayoutWithCellClass:(Class)cellClass
                                         heightArray:(NSArray <NSNumber *> *)heightArray
                                           heightSel:(SEL)heightSel;

你是说,用这个方法控制瀑布流吗? 那请问第二个 section 中有两种 item 样式,如何声明设置呢?这个方法似乎只能设置一种 cell 类型。

tisfeng avatar Apr 06 '21 08:04 tisfeng

你这个多种cell,去设置会增加配置的复杂性,你的需求是这两种cell样式交错显示?

tigerAndBull avatar Apr 06 '21 08:04 tigerAndBull

额,不是,目前就两种 cell,其中只有第二个 cell 特别一些,是一个 collectionView 实现的标签卡片。 暂时现在不考虑更复杂的需求,仅仅显示上述页面的骨架,请问该如何实现?

tisfeng avatar Apr 06 '21 08:04 tisfeng

所以你的需求是,两个section,section为1时是瀑布流,只有瀑布流需要骨架,为一种类型cell

tigerAndBull avatar Apr 06 '21 09:04 tigerAndBull

两个 section 都需要骨架,第一个 section 是单一类型 cell,第二个 section 其中有一个特别的不同类型 cell,其余的是卡片样式 cell,现在我的问题是,不知道怎么去实现第二个 section 的两种 cell 骨架显示。。

tisfeng avatar Apr 06 '21 09:04 tisfeng

可以的,但是我需要给你开个接口,我手上还有点事情,可能要等等

tigerAndBull avatar Apr 06 '21 09:04 tigerAndBull

好的可以,感谢!

tisfeng avatar Apr 06 '21 09:04 tisfeng

同问

sga773646787 avatar Apr 06 '21 09:04 sga773646787

看了demo中的都是支持一个section,一种cell样式的。

sga773646787 avatar Apr 06 '21 09:04 sga773646787

只有瀑布流是一个section一个样式,其他都是可以多样式的

发自我的iPhone

------------------ 原始邮件 ------------------ 发件人: sga773646787 @.> 发送时间: 2021年4月6日 17:36 收件人: tigerAndBull/TABAnimated @.> 抄送: tigerAndBull @.>, Comment @.> 主题: 回复:[tigerAndBull/TABAnimated] 请问如何配置 collectionView 具有多个 section,且同一 section 有多种 item 样式的骨架? (#142)

看了demo中的都是支持一个section,一种cell样式的。

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

tigerAndBull avatar Apr 06 '21 09:04 tigerAndBull

切面管理,除了瀑布流,你只要用array系列的方法,就可以多样式

tigerAndBull avatar Apr 06 '21 09:04 tigerAndBull

请问作者大大,array是针对多section的,如果页面中有多个section,每个section下面有不同的样式的cell是怎么设置tabAnimated

sga773646787 avatar Apr 06 '21 09:04 sga773646787

当一个section对应多个cell样的样式,我看到的注释是:视图结构要求:1个section对应多个cell,且只有1个section,这个时候视图只能有一个section

sga773646787 avatar Apr 06 '21 09:04 sga773646787

你可以精准定位section绑定cellClass, 如果你非要在特定section绑定cellClassArray并不支持,但你可以给section+1输送你需要的cellClass。 这个需求同样也是api层面的问题,你在设置的时候,又需要考虑,哪个row显示哪种cell,需要配置好 一般骨架屏不会搞的这么复杂,所以没有专门针对这个扩展到二维

发自我的iPhone

------------------ 原始邮件 ------------------ 发件人: sga773646787 @.> 发送时间: 2021年4月6日 17:42 收件人: tigerAndBull/TABAnimated @.> 抄送: tigerAndBull @.>, Comment @.> 主题: 回复:[tigerAndBull/TABAnimated] 请问如何配置 collectionView 具有多个 section,且同一 section 有多种 item 样式的骨架? (#142)

请问作者大大,array是针对多section的,如果页面中有多个section,每个section下面有不同的样式的cell是怎么设置tabAnimated

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

tigerAndBull avatar Apr 06 '21 09:04 tigerAndBull

是的,没有建立二维结构

发自我的iPhone

------------------ 原始邮件 ------------------ 发件人: sga773646787 @.> 发送时间: 2021年4月6日 17:47 收件人: tigerAndBull/TABAnimated @.> 抄送: tigerAndBull @.>, Comment @.> 主题: 回复:[tigerAndBull/TABAnimated] 请问如何配置 collectionView 具有多个 section,且同一 section 有多种 item 样式的骨架? (#142)

当一个section对应多个cell样的样式,我看到的注释是:视图结构要求:1个section对应多个cell,且只有1个section,这个时候视图只能有一个section

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

tigerAndBull avatar Apr 06 '21 15:04 tigerAndBull

我现在tableView里面有4种cell,3个section,第一个section的最后一个cell是单独的一个样式,这个样式使用的是估算高度,骨架屏里面开启动画后第一个section的最后一个cell的高度不对了。 未开启骨架屏 Simulator Screen Shot - iPhone 13 Pro Max - 2021-10-09 at 15 15 13 骨架屏动画中 Simulator Screen Shot - iPhone 13 Pro Max - 2021-10-09 at 15 20 30 骨架屏动画结束 image

Snail-hash avatar Oct 09 '21 07:10 Snail-hash