简体   繁体   中英

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.

Thanks!

Have you tried passing the information to one of the TabBarController's view controllers in a property through the prepareForSegue method?

Create two properties in the 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;
   }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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