IBOutlet link to embedded view controller

前端 未结 4 907
刺人心
刺人心 2021-02-02 07:29

I have a complex iPad view that I manage by having several view controllers. I previously (before iOS6/XCode 4.5) did this by allocating my view controllers in code, and hooked

4条回答
  •  悲&欢浪女
    2021-02-02 07:58

    Another option for some cases is to capture the embedded controller using -prepareForSegue:sender:.

    For example, if I have a UINavigationController embedded within a CustomContainerViewController, I can name the embed segue embedContentStack in the storyboard and capture it in CustomContainerViewController via

    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
        if ([segue.identifier isEqualToString:@"embedContentStack"]) {
            // can't assign the view controller from an embed segue via the storyboard, so capture here
            _contentStack = (UINavigationController *)segue.destinationViewController;
        }
    }
    

提交回复
热议问题