简体   繁体   English

iOS-导航控制器到选项卡栏控制器

[英]iOS - navigation controller to tab bar controller

In my storyboard, I have a Table View Controller and I want to be able to tap on an item in the table view and go to a detail view with more information. 在我的情节提要中,我有一个“表视图控制器”,并且希望能够在表视图中点击一个项目并转到带有更多信息的详细信息视图。 In the detail view, I'd like it to be like the Tab Bar Controller as the detail view can be separated into 2 categories. 在详细视图中,我希望它像“标签栏控制器”一样,因为详细视图可以分为两类。

Is this possible? 这可能吗? At the moment I can do it in my storyboard, but after searching around, I can't seem to find out how to pass the details of the selected item from the Table View Controller to the Tab Bar controller. 目前,我可以在情节提要中执行此操作,但是在四处搜索之后,似乎无法找出如何将所选项目的详细信息从“表格视图”控制器传递到“标签栏”控制器。

Am I missing something obvious? 我是否缺少明显的东西? Or going about this wrong? 还是要解决这个错误? I'm new to iOS development so any advice would be appreciated. 我是iOS开发的新手,所以任何建议都将不胜感激。

Thanks! 谢谢!

Have you tried passing the information to one of the TabBarController's view controllers in a property through the prepareForSegue method? 您是否尝试过通过prepareForSegue方法将信息传递给属性中TabBarController的视图控制器之一?

Create two properties in the TableView Controller: 在TableView Controller中创建两个属性:

@property (strong, nonatomic) UITabBarController *tabBarController;
@property (strong, nonatomic) YourViewController *firstViewController;

Then Use: 然后使用:

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
   NSLog(@"prepareForSegue: %@", segue.identifier);

   if ([segue.identifier isEqualToString:@"mySegueID"]) {

       self.tabBarController = (UITabBarController*) [segue destinationViewController];
       self.firstViewController = [self.tabBarController.viewControllers objectAtIndex:0];
       self.firstViewController.SOMEPROPERTY = SOMEVALUE;
   }
}

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

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