iPhone应用程序-UINavigationController和UITabBarController的组合

发布于 2024-09-10 17:43:20 字数 1154 浏览 3 评论 0原文

我想制作具有复杂视图的登录应用程序。

需求流程如下:

Login Page --> Menu Page --> Detail Page with Tab Control. --> Navigation Page

这里的“详细信息页面”再次是两个视图的组合。导航视图和选项卡视图。

即“详细信息页面”顶部将有一个导航控件(导航栏),控件的其余部分是选项卡控件,以便用户可以随时在选项卡之间切换。如果用户从导航控件中按“下一步”,他们将转到新页面,并且可以通过从下一页按“返回”再次返回到“选项卡视图”。

另外,我还有很多不适合单个选项卡视图的选项卡,因此我希望最后一个选项卡像更多选项一样,并且会转到不同的视图(表格视图的自定义)。

目前我已经开发了 Window 基础应用程序,如下所示。

  1. 主控制器(MainSwitcherViewController)是从委托初始化的。
  2. 这个主控制器引用了多个其他UIViewsController

    例如:

    • LoginViewController 即 UIViewController。
    • MenuViewController 即 UIViewController。
  3. 最初我显示 LoginViewController。

  4. 成功登录后,我会显示 MenuViewController。
  5. 从 MenuViewController 上的任何操作(选择菜单 - 当前添加为 UIButton),我将打开新视图,但我想进入导航视图和选项卡视图组合视图,而不是新视图(UIViewController),如上所述。

这是我的问题:

  1. 我设计屏幕/视图的方法是正确的还是我需要采取另一种方法?
  2. 如何在 UIViewController 和 TabViewController 或 NavigationViewController 之间切换?
  3. 如何创建在顶部和底部 TabBarViewControl 上具有导航控件的组合控制器,以便每个选项卡导航控件都可见(共享)。

我是 iPhone 应用程序开发的初学者,

请给我一些具有类似示例的指针或链接。

提前致谢。

I want to make the login app with the complicated views.

Requirement flows as below:

Login Page --> Menu Page --> Detail Page with Tab Control. --> Navigation Page

Here the 'Detail Page' is again a combination of two views. Navigation View and Tab View.

i.e. 'Detail Page' will have a Navigation Control (Navigation Bar) on top and rest of the control is a Tab Control so that the user can switch between tabs at any point. If a user presses 'Next' from the navigation control, they will go to new page and can come back again to the 'Tab View' by pressing back from the next page.

Also I have lot more tabs which don't fit into a single tab view so I want the last tab to be like more option and will go to different views (either custom of table view).

Currently I have developed the Window base application as under.

  1. Main Controller (MainSwitcherViewController) which is got initialized from the delegate.
  2. This main controller has a reference of multiple other UIViewsController

    For example:

    • LoginViewController which is UIViewController.
    • MenuViewController which is UIViewController.
  3. Initially I show the LoginViewController.

  4. On successful login I show the MenuViewController.
  5. And from the MenuViewController on any action (selection of Menu - currently added as UIButton), I am opening the NEW View but instead of New View (UIViewController) I want to go in Navigation View and Tab View combination View as explained above.

Here is my question:

  1. Is my approach of designing the screen/views is correct or do I need to take another approach?
  2. How to switch between UIViewController to TabViewController or NavigationViewController?
  3. How to create combined Controller having Navigation Control on Top and on bottom TabBarViewControl such a way that for each tab Navigation Control is visible (shared).

I am a beginner at iPhone app development,

Please give me some pointers or links having similar kinds of examples.

Thanks in advance.

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

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

发布评论

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

评论(1

凉宸 2024-09-17 17:43:21

好的,首先你的方法没问题。您可以在与 UINavigationController 相同的类中拥有 UITabBarController。只需创建选项卡栏控制器,并在同一类中创建导航控制器。用户将能够从该视图中使用两者。

为此,在带有选项卡栏的类中:

UITabBarController *mainTabBar = [[UITabBarController alloc] init];

然后将视图添加到该选项卡栏控制器。在其中一个 UIViewController 中,添加一个导航控制器:

UIViewController *mainViewController = [[MainViewController alloc] init];
mainViewController.title = @"Welcome";
UINavigationController *mainViewNavController = [[UINavigationController alloc] init];
[mainViewNavController pushViewController:mainViewController animated:NO];

然后只需将选项卡栏与新视图一起添加到视图中:

mainTabBar.viewControllers = [NSArray mainViewNavController, nil];

记住仅将导航控制器添加到选项卡栏控制器中,因为如果您像平常一样添加类,它就会将不具备导航控制器功能。

希望这有帮助,如果没有,我很乐意澄清任何事情。

Ok, first your approach is fine. You can have a UITabBarController in the same class as a UINavigationController. Just create the tab bar controller and in the same class also create the navigation controller. The user will be able to use both from within that view.

To do this, in the class with the tab bar:

UITabBarController *mainTabBar = [[UITabBarController alloc] init];

Then add a the Views to that Tab Bar Controller. In one of those UIViewController, add a navigation controller:

UIViewController *mainViewController = [[MainViewController alloc] init];
mainViewController.title = @"Welcome";
UINavigationController *mainViewNavController = [[UINavigationController alloc] init];
[mainViewNavController pushViewController:mainViewController animated:NO];

then just add the tab bar to the view along with the new views:

mainTabBar.viewControllers = [NSArray mainViewNavController, nil];

remember to only add the navigation controller to the tab bar controller becauase if you add the class as you normally would, it will not have the navigation controller features.

Hope this helps, if not, I'll be happy to clearify anything.

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