在IB中哪里添加带有SegmentedControl的工具栏?

发布于 2024-10-02 13:06:37 字数 300 浏览 0 评论 0原文

我在 MainWindow.xib 中有一个 NavigationController。它加载一个 RootViewController,它基本上管理一个 TableView(在 .xib 中有一个包含表视图和搜索栏的视图)。现在我想添加一个分段控件来在表视图和地图视图之间切换。 我的想法是使用相同的 RootViewController 管理地图视图,为此我将在 RootViewController.xib 中创建一个带有地图视图和搜索栏的视图
但是我可以将带有分段控件的工具栏放在哪里?它必须在表格和地图视图中都可见,但我没有成功实现这一点。
谢谢
弗兰

I have a NavigationController in MainWindow.xib. It loads a RootViewController that basically manages a TableView (in the .xib there is a view which contains the table view and a search bar). Now I'd like to add a segmented control to switch between the table view and a map view.
My idea is to manage the map view with the same RootViewController and for this I'll create a view with a map view and a search bar in RootViewController.xib
But where I can put the toolbar with the segmented control? It must be visible both in the table and the map view, but I don't succeed in achieving this.
Thanks
Fran

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

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

发布评论

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

评论(1

洛阳烟雨空心柳 2024-10-09 13:06:37

我认为你想要做的是将地图和表格视图放在另一个容器 UIView 中。然后您可以显示/隐藏或交换该容器内的两个视图。然后您可以将容器视图的高度减少 44px 并放入工具栏中。在 IB 中,您可以将分段控件拖放到工具栏上,瞧。因此,您的根视图控制器在顶层包含两个项目:工具栏和通用 UIView 容器。地图和表格视图将是容器的子视图,您可以使用工具栏中分段控件上的 valueChanged UIControlEvent 来调用交换地图和表格视图的方法。

I think what you want to do is put the map and table views in another container UIView. Then you can show/hide or swap the two views within that container. Then you can reduce the height of the container view by 44px and drop in a toolbar. In IB you shield be able to drop a segmented control onto the toolbar and voila. So your root view controller contains two items at the top level: A toolbar and a generic UIView container. The map and table view will be subviews of the container and you can use the valueChanged UIControlEvent on the segmented control in the toolbar to call a method to swap the map and table views.

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