子View Controllerで追加の処理を行うことなく、必要に応じて子View Controllerを元に戻すために、子View Controllerを破棄した後も保持する必要があります。以下のリンクを使用してそれを達成しようとしました:
View Controller Containment は iOS 5 でどのように機能しますか?
これらのリンク(および同様の他のリンク)は、子View Controllerを持ってくるか、それを却下する目的を果たしましたが、「保持」することはありませんでした。以下の私のコードを見つけてください:
/* Adding a child view controller */
self.detailsViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"DetailsViewController"];
self.detailsViewController.name = @"DetailsText";
// data to do "processing in viewDidLoad of child"
self.detailsViewController.someOtherDataForProcessing = someOtherDataForProcessing;
self.detailsViewController.delegate = self;
[self addChildViewController:self.detailsViewController];
self.detailsViewController.view.frame = CGRectMake(0, self.view.frame.size.height, self.view.frame.size.width, 200);
[self.view addSubview:self.detailsViewController.view];
/* Bringing the child up on swipe gesture */
[UIView animateWithDuration:0.5 animations:^{
self.detailsViewController.view.frame = CGRectMake(0, 100, self.view.frame.size.width, 200);
} completion:^(BOOL finished) {
[self.detailsViewController didMoveToParentViewController:self];
}];
/* Moving child down when back pressed on child */
[UIView animateWithDuration:0.5 animations:^{
[self.detailsViewController willMoveToParentViewController:nil];
self.detailsViewController.view.frame = CGRectMake(0, self.view.frame.size.height, self.view.frame.size.width, 200);
} completion:^(BOOL finished) {
[self.detailsViewController.view removeFromSuperview];
[self.detailsViewController removeFromParentViewController];
}];
「親のスワイプで再び」子コントローラーを使用する必要がある場合は、プロセス全体をもう一度実行する必要があります。私が必要とするのは、「スワイプジェスチャで子を起動する」プロセスを実行することだけであり、インスタンス化は子コントローラーでデータの処理を行うため(時間がかかります)、再度インスタンス化しないでください。
私は iOS アプリ プログラミングの初心者なので、これが明らかな質問である場合はご容赦ください。