弹出到 UINavigationController 的根目录后如何在 UIView 的底部显示 UIToolBar?

发布于 2024-09-24 15:07:54 字数 1243 浏览 1 评论 0原文

我无法显示位于视图底部的 UIToolbar,其中视图推动导航控制器,然后使用后退按钮弹出回视图。

在我创建的NIB中:

UIViewController RootViewController containing a
   UIView  containing a
       UIToolbar at bottom of UIView

在RootViewController中,我创建下一个UIViewController,NextViewController,在其中创建一个NavigationController:

UIViewController RootViewController containing a
   UIViewController NextViewController containing a 
      NavigationController

在NextViewController中,我可以从RootViewController看到UIToolbar。当我使用导航控制器中的后退按钮弹回 NextViewController 时,我无法再从 RootViewController 中看到 UIToolbar。有谁知道如何使 UIToolbar 可见?

我认为可行的一种方法是获取指向 UIToolbar 的指针并将其作为子视图添加到导航控制器中,如下所示:

AppDelegate *appDelegate    = [[UIApplication sharedApplication] delegate];
RootViewController *rootViewController = appDelegate.rootViewController;

UIView *rootViewUIView               = rootViewController.view;
UIToolbar *rootViewUIToolbar         = rootViewUIView.toolbar;

[self.navigationController.view addSubview:rootViewUIToolbar];

但我收到错误:“请求成员 rootViewUIToolbar 位于非结构或联合中”,该行:

UIToolbar *rootViewUIToolbar         = rootViewUIView.toolbar;

关于如何使用后退按钮从导航控制器弹回根视图后显示工具栏有什么想法吗?

I can't show a UIToolbar that was at the bottom of a view, where the view pushed a navigation controller and then popped back to the view using the back button.

In a NIB I've created:

UIViewController RootViewController containing a
   UIView  containing a
       UIToolbar at bottom of UIView

In RootViewController I create next UIViewController, NextViewController, within which I create a NavigationController:

UIViewController RootViewController containing a
   UIViewController NextViewController containing a 
      NavigationController

In NextViewController I can see the UIToolbar from RootViewController. When I pop back to NextViewController, using the back button, from the NavigationController I can no longer see the UIToolbar from RootViewController. Does anyone know how to make the UIToolbar visible?

One approach I thought would work was to get a pointer to the UIToolbar and add it as a subview to the navigation controller as:

AppDelegate *appDelegate    = [[UIApplication sharedApplication] delegate];
RootViewController *rootViewController = appDelegate.rootViewController;

UIView *rootViewUIView               = rootViewController.view;
UIToolbar *rootViewUIToolbar         = rootViewUIView.toolbar;

[self.navigationController.view addSubview:rootViewUIToolbar];

But I get the error: "Request for member rootViewUIToolbar in something not a structure or a union" for the line:

UIToolbar *rootViewUIToolbar         = rootViewUIView.toolbar;

Any ideas on how to show the toolbar after popping back to the root view from the navigation controller using the back button?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文