Linking child view controllers to a parent view controller within storyboard

后端 未结 5 1884

Can you associate child view controllers to a custom container view controller in Storyboard?

I can link child view controllers to a tab view controller, and I can l

5条回答
  •  遥遥无期
    2020-11-30 19:40

    As something of a combo of Caleb and Matt's answers, I did:

    -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
        if ([segue.identifier isEqualToString:@"cpdc_check_embed"]) {
            self.checkVC = segue.destinationViewController;
        }
    }
    

    ...where checkVC is a property on the container controller:

    @property (weak,nonatomic) PXPCheckViewController * checkVC;
    

    You just have to set your embed segue's Storyboard ID to whatever you want (in this case, cpdc_check_embed):

    check embed screen in Xcode

    ...and then check the identifier in -prepareForSegue:sender:.

    Still not an outlet, but cleaner than Matt's (IMHO) and more specific than Caleb's, and you still get a nice-looking storyboard:

    enter image description here

提交回复
热议问题