gpt4 book ai didi

ios - 如何创建类似 UITableView 结构的树?

转载 作者:行者123 更新时间:2023-11-29 12:39:05 26 4
gpt4 key购买 nike

我有一个 NSDictionaries 的 NSMutableArray,看起来像这样

<Blank BlankName="V6" Type="Line" CurrentType="Crypt"/>
<Blank BlankName="T3" Type="Ion" CurrentType="Crypt"/>
<Blank BlankName="HU" Type="Sia" CurrentType="Crypt"/>
<Blank BlankName="HF" Type="Ion" CurrentType="Crypt"/>
<Blank BlankName="HU5" Type="Sia" CurrentType="Crypt"/>
<Blank BlankName="HU6" Type="Sia" CurrentType="Less"/>
<Blank BlankName="V6" Type="Line" CurrentType="Less"/>
<Blank BlankName="V66" Type="Line" CurrentType="Less"/>

我想弄清楚如何将它放入树状结构中以显示在 UITableView 中。

在这个结构中会有3种信息

Header (unique) - CurrentType
- Sub Header (unique) - Type
- Info (multiple items) - BlankName

所以使用 xml 作为示例,UITableView 看起来像这样。

Crypt
- Ion
- T3
- HF
- Line
- V6
- Sia
- HU
- HU5
Less
- Line
- V6
- V66
- Sia
- HU6

我真的没有任何我一直在研究的示例代码,因为我真的不知道从哪里开始,例如,是否有适合存储此类信息的特定结构。我没有研究排序,因为我不知道如何存储它。

提出这个问题后,我仍在阅读和调查。

最佳答案

要创建平面数组 - 更改解析代码以创建这样的数组:

[ <Dictionary containing Header 1 title, indentation 0>,
(Dictionary containing Sub-Header 1 title, indentation 1),
-Dictionary containing Sub-Header-info 1 title, indentation 2-,
-Dictionary containing Sub-Header-info 1 title, indentation 2-,
.....
(Dictionary containing Sub-Header 2 title, indentation 1),
.....
<Dictionary containing Header 2 title, indentation 0>,
.....
and so on.
]

您可以创建自己的自定义对象类来保存缩进和标题以及其他内容的值,而不是字典。会更容易使用:)干杯:)

关于ios - 如何创建类似 UITableView 结构的树?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25517841/

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