UITabBarcontroller、UITableView 和 PushView

发布于 2024-09-27 11:36:47 字数 222 浏览 1 评论 0原文

我有一个带有一组选项卡的 UITabBarController。 其中一些在选择后会向您显示一个表格。 如果触摸表格的单元格,则使用“pushViewController”将用户带到单元格本身中的对象的详细信息屏幕。

当我单击另一个选项卡并且位于详细信息页面时,我会看到新的选项卡页。 这很好。当我单击返回上一个选项卡时,我想再次显示表格而不是详细信息页面...

这可能吗?

谢谢!

I have a UITabBarController with a set of tabs.
Some of them, when selected, show you a table.
The cells of the table, if touched, bring the user to a detail screen of the object in the cell itself using a "pushViewController".

When I click to a different tab, and I am in the detail page, I see the new tab page.
And this is fine. When I click back to the previous tab I would like to have shown again the table and not the detail page...

Is this possible?

Thanks!

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

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

发布评论

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

评论(2

铜锣湾横着走 2024-10-04 11:36:47

这是可能的。代码:

// Called when the user selected a tab. In iOS3+, called even when no change occurs.
- (void)tabBarController:(UITabBarController *)tabbarcontroller didSelectViewController:(UIViewController *)viewController
{
    UINavigationController *nav = (UINavigationController *)viewController;
    [nav popToRootViewControllerAnimated: NO];
}

说明:

  • 这是在您的 AppDelegate 中。
  • 您的 AppDelegate 是 UITabBarControllerDelegate。
  • 您将 UITabBarController 的委托(在 InterfaceBuilder 中)设置为 AppDelegate。
  • 您的选项卡必须包含作为导航控制器的根控制器(必须如此,否则您将无法“推送”详细信息)。

It is possible. Code:

// Called when the user selected a tab. In iOS3+, called even when no change occurs.
- (void)tabBarController:(UITabBarController *)tabbarcontroller didSelectViewController:(UIViewController *)viewController
{
    UINavigationController *nav = (UINavigationController *)viewController;
    [nav popToRootViewControllerAnimated: NO];
}

Explanations:

  • this is in your AppDelegate.
  • Your AppDelegate is a UITabBarControllerDelegate.
  • You set your UITabBarController's delegate (in InterfaceBuilder) to the AppDelegate.
  • Your tabs must contain root controllers that are navigation controllers (must be, else your wouldn't be able to 'push' details).
归途 2024-10-04 11:36:47

请参阅 UITabBarControllerDelegate 协议来设置切换选项卡时将通知哪个控制器,然后使用它弹出详细控制器。

顺便说一句,您还可以在界面生成器中完成大部分导航控制器设置,如下所示:

alt text

See the UITabBarControllerDelegate protocol to set up which controller will be notified when tabs are switched then just pop the detail controller using that.

BTW, you can also do most of this navigation controller setup in interface builder like this:

alt text

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