点击分段控制时更改表格视图。与 APPSTORE 应用程序完全相同。怎么做呢?

发布于 2024-08-17 18:36:51 字数 188 浏览 2 评论 0原文

我有一个 SampleViewController,其中在导航栏下方的顶部添加了一个分段控件(不在其中)。现在在分段控件下方,我想要一个从另一个类 CommonTableViewController 加载的 tableView。当点击某个段时,应该加载来自同一 CommonTableViewController 的新 tableView。怎么办呢? 提前致谢。

I am having a SampleViewController in which a segmentedControl is added at the top below nav bar(not inside it).Now below the segmentedControl i want a tableView which loads from another class CommonTableViewController. When a segment is tapped the a new tableView from same CommonTableViewController should be loaded. How can it be done?
thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

〃温暖了心ぐ 2024-08-24 18:36:51

我使用数组来填充我的 tableView...

在我的 segmentedControlClicked 方法中...我根据选择的段更改数组中的数据,然后使用这行代码:

[self.tableView reloadData];

I use an array to populate my tableView...

In my segmentedControlClicked method... I change the data in the array based on which segment was selected and then use this line of code:

[self.tableView reloadData];
杀お生予夺 2024-08-24 18:36:51

如果您已经有 2 个 UITableView,则只需从屏幕上删除第一个并添加另一个即可。根据

[tableView1 removeFromSuperview];
[self.view indertSubview:tableView2 atIndex:self.view.subviews.count];

具体情况,您可能还需要考虑拥有一个 tableView 并仅更改数据。

If you already have 2 UITableViews then just remove the first from the screen and add the other. LIke

[tableView1 removeFromSuperview];
[self.view indertSubview:tableView2 atIndex:self.view.subviews.count];

Depending on the case, you might also want to consider haveing one tableView and just changing the data.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文