UINavigationBar 与 UITabBar 内的 TableView 和分段控件

发布于 2024-09-16 12:01:02 字数 625 浏览 7 评论 0原文

我有一个标签栏应用程序。第二个选项卡有一个带有导航控制器的向下钻取表列表。我还想在工具栏中实现分段控件,该工具栏根据分段控件中选定的开关显示不同的表条目。我对如何实现这个有点困惑?

截屏 - alt text

这是第二个选项卡控制器中的视图,是通用 UIViewController 的实例。蓝色背景是包含分段控件 (1,2,3,4) 的 UIView。顶部的钢蓝色导航栏是 Interface Builder 中的模拟 UI 元素。我需要放置一个导航控制器,使其具有一个列表视图,该视图根据分段控制 UI 中选择的开关而变化。

我有以下选项

  1. 添加 UINavController 作为第二个选项卡的根控制器,直接在其中包含表视图。在这种情况下,我如何适应具有分段控件的 UIToolbar?

  2. 我将 UISegmentedControl 添加为第二个选项卡视图控制器视图的一部分,并将基于导航的表视图添加为该视图的另一个元素。这可行吗?如何将基于导航的控制器添加到 UIView 并控制框架,使其不覆盖 UIToolBar。

我希望我说得有道理。如果您有任何建议,请告诉我。谢谢。

I have a tabbar application. Second tab had a drill down table list with Navigation Controller. I also want to implement a segmented control inside a tool bar that shows different table entries as per the selected switch in segmented control. I am a little confused as to how to implement this?

Screen-shot -
alt text

This is the view in second tab controller an instance of the generic UIViewController. Blue Background is a UIView that contains a segmented control (1,2,3,4). The steel blue navigation bar at the top is a simulated UI Element from Interface Builder. I need to put a navigation Controller such that it has a list table view that changed depending on the switch selected in segmented control UI.

I have following options

  1. Add UINavController as root controller for second tab directly with table view inside it. In that case how do I accomodate the UIToolbar having segmented control?

  2. I add UISegmentedControl as part of the view of Second Tab's view controller and add navigation based table view as another element to that view. Is this doable? How can I add a nav based controller to a UIView and control the frame so that it does not cover the UIToolBar.

I hope I am making sense. Please lemme know if you have any suggestions. Thanks.

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

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

发布评论

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

评论(3

誰ツ都不明白 2024-09-23 12:01:02

我就是这样实现的。在 IB 中,在 MainWindow.xib 中,我有一个 tabbarController,我将第二个选项卡的类标识设置为 UINavigationConrtroller。然后,我为第二个选项卡创建了主视图控制器,该选项卡具有分段控件和表视图作为导航控制器的根视图控制器。这完全按照我想要的方式运行。感谢大家的帮助。

This is how I achieved it. In IB, in MainWindow.xib where I have a tabbarController, I made the class identity of the second tab to a UINavigationConrtroller. Then I made the main view Controller for second tab that had the segmented control and the Table View as a rootViewController to the NavigationController. This functioning exactly as I wanted. Thanks all for your help.

枯叶蝶 2024-09-23 12:01:02

您可以添加 UINavigationController 来代替 UITabbarcontroller 中的 UIViewController ,并将具有 UISegmentControl 的 UIViewController 放入 UINavigationController 中,并在 UITabbarcontroller 中添加

,阅读它看起来很混乱,但尝试实现其工作

步骤 1:xcode--> 新项目--> 选项卡应用程序

第2步:打开主窗口的xib,选择tabbarcontroller并打开检查器。您可以看到视图控制器列表将其类更改为 uinavigationController。
如果您在第二个选项卡中需要 uinavigationController,则仅将第二个选项卡类更改为 uinavigationController

第 3 步:创建新的 uiviewcontroller。打开它的 xib 并向其添加 uitableview 和段控件。

Setp 4:现在展开 tabbarcontroller 并检查您的第二个选项卡是否有导航控制器,现在将您的 uiviewcontroller 添加到导航控制器的视图控制器中

you can add UINavigationController in place of UIViewController in UITabbarcontroller and Put your UIViewController who haveing UISegmentControl in UInavigationController who add in UITabbarcontroller

in reading its looks confusing but try to implement its work

Step 1: xcode-->new Project-->tabbar application

Step 2: open xib of main window select tabbarcontroller and open inspector. in that you able to see list of view controllers change their class to uinavigationController.
if you need uinavigationController in second tab then change only secong tab class to uinavigationController

step 3: create new uiviewcontroller. open its xib and add uitableview and segment control to that.

Setp 4: now expand tabbarcontroller and check your second tab have navigationcontroller now add your uiviewcontroller in navigationcontroller's viewcontroller

倒带 2024-09-23 12:01:02

根据您的要求,您无法避免使用代码 - 我的意思是您无法通过 IB 中的连接来设置所有内容。

我将创建一个 UIViewController(我们称之为容器),它将包含分段控件和导航控制器。

  • 您应该将第二个选项卡设置为视图控制器并将其指向容器。
  • 容器的视图(如果需要,则为 XIB)应包含将与底部对齐的分段控制器和一个将填充视图其余部分并具有其 IBOutlet 的容器视图。
  • 容器还应该有一个将在 viewDidLoad 中启动的导航控制器成员。
  • 您谈论的表视图也应该构建在自己的 XIB 中,并拥有自己的视图控制器,该控制器将被设置为导航控制器的根视图控制器...

告诉我它是否太混乱/复杂...

According to your requirements you can't avoid working with code - I mean that you can't set everything by connections in IB.

I would create a UIViewController (let's call it container) that will contain the segmented control and the navigation controller.

  • You should set the second tab to be a view controller and point it to the container.
  • Container's view (XIB if you want) should contain the segmented controller that will be aligned to bottom and a containerView that will fill the rest of the view and will have its IBOutlet.
  • Container should also have a navigation controller member that will be initiated in viewDidLoad.
  • The table view that you talk about should also be built in its own XIB and have its own view controller that will be set as root view controller to the navigation controller...

Tell me if it's too confusing / complicated...

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