mainUIViewControllerと namedがありAddInformationControllerます。これmainViewControllerには 2 つありUIContainerViewます。それぞれにUITableViewController. テーブル ビュー コントローラの名前はInformationSegmentControllerおよびResultSegmentControllerです。
私はこれを入れましたAddInformationController:
InformationSegmentController *isc = [self.storyboard instantiateViewControllerWithIdentfier:@"InformationSegmentController"];
ResultSegmentController *rsc = [self.storyboard instantiateViewControllerWithIdentifier: @"ResultSegmentController"];
[self addChildViewController: isc];
[self addChildViewController: rsc];
InformationSegmentControllerクラスまたはクラスのいずれかで、ResultSegmentControllerこれをログに記録しようとしました:
NSLog(@"%@",self.parentViewController);
しかし、残念ながら、それは nil です。parentViewController を正しく取得するにはどうすればよいですか? を使用する必要がありprepareForSegueますか?
// 質問の更新:
addChildViewControllerストーリーボードでこれらの childViewControllers を直接作成すると、メソッドを再度呼び出す必要がないことがわかりました。
私は試してみましNSLog(@"%@", self.childViewControllers)たがAddInformationController、結果にはInformationSegmentControllerクラスとResultSegmentControllerクラスが含まれています。
しかし、問題は、NSLog(@"%@", self.parentViewController)両方の childViewContorllersを呼び出すviewDidLoadと、結果が nil になることです。