Change Container View Content with Tabs in iOS

前端 未结 5 1836
陌清茗
陌清茗 2021-01-30 18:52

I\'m trying to make a form that spans three tabs. You can see in the screenshot below where the tabs will be. When the user taps a tab, the Container View should update and show

5条回答
  •  既然无缘
    2021-01-30 19:06

    have a member variable to hold the viewController:

    UIViewController *selectedViewController;
    

    now in the IBActions, switch that AND the view. e.g.

    - (IBAction)tab1:(id)sender {
         UIViewController *viewController1 = [self.storyboard instantiateViewControllerWithIdentifier:@"vc1"];
    
         _container.view = viewController1.view;
         selectedViewController = viewController1;
    }
    

    to fire view did appear and stuff call removeChildViewController, didMoveToParent, addChildViewController, didMoveToParent

提交回复
热议问题