I need to retain child view controller after its dismissal to move it back when needed without extra processing in child view controller. I have tried achieving it using below links:
How does View Controller Containment work in iOS 5?
These links (and similar others) did serve the purpose of bringing child view controller or dismissing it but not "retaining it". Please find my code below:
/* 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];
}];
If i need to bring child controller "again on swipe on parent", I have to go through the whole process again. What i need is just to do "Bringing the child up on swipe gesture" process and not instantiate again because instantiating will do processing of data in child controller (time consuming).
I am a noob to iOS app programming so please bear with me if this is an obvious question.