简体   繁体   English

从视图控制器移动到标签栏控制器

[英]Move from view controller to tab bar controller

When you create a tab bar controller via the interface and not programatically you dont have a tab bar controller class. 当您通过界面创建标签栏控制器而不是以编程方式创建标签栏控制器类时。 How do you move from a view controller to this tab bar controller in a case such as this? 在这种情况下,如何从视图控制器移动到此标签栏控制器?

At first make the tabbarcontroller then make uiview controller ...such as... 首先让tabbarcontroller然后制作uiview控制器......比如...

NSMutableArray *listOfViewControllers = [[NSMutableArray alloc] init];

        tab1view = [[tab1viewcontroller alloc] initWithNibName:@"tab1viewcontroller" bundle:nil];
        [listOfViewControllers tab1view];
        [tab1view release];

        tab2view = [[tab2viewcontroller alloc] initWithNibName:@"tab2viewcontroller" bundle:nil];
        [listOfViewControllers tab2view];
        [tab2view release];

        [self.tabBarController setViewControllers:listOfViewControllers animated:YES];

i think it will help you. 我认为它会对你有所帮助。

You could try and create the tab bar controller first. 您可以先尝试创建标签栏控制器。 Then show the full-screen splash screen modally (eg without animation, so that user won't notice the tab bar controller) and off that splash screen you present location selector. 然后以模态方式显示全屏启动画面(例如,没有动画,以便用户不会注意到标签栏控制器)并关闭该启动画面,显示位置选择器。 Once the user is done with it you dismiss both modal controllers revealing tab controller. 用户完成后,您将关闭两个显示标签控制器的模态控制器。

If you need to set up view controllers in your tab bar controller based on the information you're getting from location selector you can do it eg via a delegate, that is: 如果您需要根据从位置选择器获取的信息在标签栏控制器中设置视图控制器,您可以通过委托来完成,即:

  1. Implement delegate for splash screen and location selector 为启动画面和位置选择器实现委托
  2. Instantiate tab bar controller 实例化标签栏控制器
  3. Show the splash screen, setting current vc of tab bar controller a delegate of the splash screen 显示启动画面,将标签栏控制器的当前vc设置为启动画面的代理
  4. Show location selector, setting its delegate to the same view controller (you'll have the handle in splash screen) 显示位置选择器,将其委托设置为同一个视图控制器(您将在启动画面中拥有句柄)
  5. Once user dismisses location selector you inform the delegate about it and it's able to collect needed data from the location selector. 一旦用户关闭位置选择器,您就会通知代表,并且能够从位置选择器收集所需的数据。

I hope it helps. 我希望它有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM