实现UITableView树结构 [英] Implementing UITableView Tree Structure

查看:147
本文介绍了实现UITableView树结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图设置一个 UITableView 来显示嵌套线程项。我使用Core Data和一个 NSFetchedResultsController ,但不知道我的方法应该是什么。我想显示如下信息:

I'm trying to setup a UITableView for displaying nested threaded items. I'm using Core Data and a NSFetchedResultsController, but am not sure what my approach should be. I want to display the information like this:


  • 项目#1 $​​ b $ b

    • 1.1

    • 项目#1.2

    • 显示全部


    • 项目#2.1

    • 项目#2.2

    • li>
    • Item #2.1
    • Item #2.2
    • Show All

    在上面,每个子部分都有一个全部显示单击将被替换为其他子项(上面的每个项目都是单个表视图单元格)。任何人做任何类似的,有任何进近提示?感谢。

    In the above, each sub-section has a 'Show All' button that when clicked will be replaced with additional subitems (each bullet above is a single table view cell). Anyone done anything similar and have any approach hints? Thanks.

    推荐答案

    我不会打扰试图将NSFetchedResultsController绑定到不是为其创建的模式。 FRC没有对嵌套表的内在支持,我认为需要更多的工作来破解嵌套表,而不是仅仅编写一个自定义的tableview控制器来处理这个问题。如果你的表将显示两个或多个实体的对象,这是双重的真实。

    I wouldn't bother trying to cram a NSFetchedResultsController into a mode it was not created for. The FRC has no intrinsic support for nested tables and I think it would take more work to hack it to do a nested table than it would to just write a custom tableview controller to handle the problem. That is doubly true if your table will display objects from two or more entities.

    此外,我谨防止在手持移动设备上使用嵌套表。 iPhone屏幕将只显示大约11个标准尺寸的行。所以,根据上面的例子,你只能在任何时候看到两个或三个节点标题。更糟糕的是,如果你有一个节点超过11叶,你只会看到一个叶子的屏幕,并且tableview的层级性质将被伪装。

    Moreover, I would caution against using nested tables on a handheld mobile. The iPhone screen will only show about 11 standard sized rows. So, given your example above, you will only see two or three node headings at anyone time. Worse, if you have a node with more than 11 leaves, you will see nothing but a screen of leaves and the hierarchical nature of the tableview will be disguised.

    在大多数情况下,每个显示在单独一个级别上的表视图层次结构几乎总是最好的设计。

    In most circumstances, a hierarchy of tableviews, each showing on a single separate level, is almost always the best design.

    这篇关于实现UITableView树结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆