gpt4 book ai didi

ios - 多个 UITableViews 在一个 UIViewController 中一次可见

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:58:29 26 4
gpt4 key购买 nike

我曾在一个 View 中看到有关多个 UITableView 的问题,但它们一次都只有一个可见的表格。请给我一些不同的东西。

在我的脑海中,我希望在一个 UIView 内的一个 UIScrollView 中显示四个 UITableView。这四个表将立即可见并填充。它们每个都有动态行数,因此 ScrollView 将允许用户滚动页面以查看不适合的行。

table 将并排放置两个,然后在它们下面并排放置下两个,这样您就可以得到一个 2x2 的正方形。

我可以(有点)全神贯注于如何在 Controller 等中对此进行编码,但我无法弄清楚如何组织层次结构。我曾尝试使用存储板在 View 中布置表格,但 10 次尝试删除控件中有 9 次都失败了,因为我显然没有完全理解这一点。

我是否需要在 UIViews 实现文件中生成 UITableViews 并将它们作为对象添加到 UIView 中?或者我可以使用 Storyboard 吗?

有人可以解释一下对象的层次结构是如何构建的吗?

在我的脑海里它会是:界面 View Controller

-> 界面 View

---> UIScrollView

------> UITableView

------> UITableView

------> UITableView

------> UITableView

但是在 Storyboard 中尝试这样做是行不通的。我假设每个 UITableView 都需要自己的 UITableViewController 以及我在其他帖子中阅读的内容,我可能需要在 UIViewController 实现文件中进行连接。

感谢任何帮助。

最佳答案

我认为您可能会尝试将 UITableViewController 拖到您的 View Controller 中,至少我没有将 4 个 TableView 添加到 ScrollView 中的问题。

我是这样添加的

1.>将 ScrollView 控件拖入 View Controller

enter image description here

enter image description here

你的 View Controller 应该是这样的:

enter image description here

2.>将表格 View 控件拖到 ScrollView 中,并设置该表格 View 的大小和位置

enter image description here

enter image description here

你的 View Controller 应该是这样的:

enter image description here

3.>然后把剩下的3个table view都拖到Scroll view上

enter image description here enter image description here

But i would like to suggest a couple of things in your case

  1. no using that much table view in the same view controller, it's a chaos in your codes to maintain all them. There are always better options than 4 table view, maybe consider collection view. or even separate the use flow.

  2. If i were you, i won't use table view inside Scroll view, they are like scroll view inside scroll view, if you don't design the interaction very very well, they become extremely hard to use.

  3. If you still want to use four table view in the same view controller after all, you want to pay extra attentions on your table view datasource and delegate. very carefully handle all the cases.

希望对你有帮助。

关于ios - 多个 UITableViews 在一个 UIViewController 中一次可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21589843/

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