将子视图控制器链接到故事板中的父视图控制器 [英] Linking child view controllers to a parent view controller within storyboard
问题描述
您可以将子视图控制器关联到Storyboard中的自定义容器视图控制器吗?
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 link one view controller to a navigation controller.
我必须对容器VC做什么以接受子VC。
What must I do to the container VC to accept child VCs?
推荐答案
作为Caleb和Matt的答案的组合,我做了:
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;
}
}
...其中 checkVC
是容器控制器上的属性:
...where checkVC
is a property on the container controller:
@property (weak,nonatomic) PXPCheckViewController * checkVC;
您只需设置 embed
segue 故事板ID
到任何你想要的(在这种情况下, cpdc_check_embed
):
You just have to set your embed
segue's Storyboard ID
to whatever you want (in this case, cpdc_check_embed
):
...然后检查 -prepareForSegue:sender:
中的标识符。
...and then check the identifier in -prepareForSegue:sender:
.
仍然不是插座,比马特(IMHO)更清晰,比Caleb更具体,你仍然得到一个漂亮的故事板:
Still not an outlet, but cleaner than Matt's (IMHO) and more specific than Caleb's, and you still get a nice-looking storyboard:
这篇关于将子视图控制器链接到故事板中的父视图控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!