gpt4 book ai didi

ios - 管理 Swift 表格 View 中的部分

转载 作者:行者123 更新时间:2023-11-30 14:06:51 25 4
gpt4 key购买 nike

我的tableview中有两个部分。第一个用于 - 一个自定义单元 Nib ,第二个 - 用于另一个。

两者的数据都是从单独的数组加载的。

但问题是 - 无论我追加数组还是执行 insertRowAtIndexPaths - 行都不会出现在这两个部分的下方,它们会追加当前部分。

示例:

Section1:
Cell1: Nib1
Cell2: Nib1
Cell3: Nib1
Section2
Cell4: Nib2

如果我追加它会这样发生

Section1:
Cell1: Nib1
Cell2: Nib1
Cell3: Nib1
Cell4: Nib1
Cell5: Nib1
Section2
Cell6: Nib2
Cell7: Nib2

我想要

Section1:
Cell1: Nib1
Cell2: Nib1
Cell3: Nib1
Section2
Cell4: Nib2
Section1:
Cell5: Nib1
Cell6: Nib1
Section2:
Cell7: Nib2

我如何实现这一目标?谢谢。

最佳答案

在您的 cellForRowAtIndexPath 方法中检查当前选定的部分是什么并在其上追加行。您可以使用 indexPath[section]

检查当前部分

关于ios - 管理 Swift 表格 View 中的部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32270386/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com