I multiple view controllers that will be displaying a dynamic view controller on a button click, here is how my view controllers are laid out:
The "calculationView" view does not display anything until the "Start" button is pressed. When the user presses the "Start" button "calculationView" in View Controller 2 displays a child view controller (not shown here).
The back arrow in View Controller 2 takes the user back to Item 1 in the tab bar and displays the same view controller in VIew Controller 2 in calculationView.
Now, everything works fine except that the content in calculationView in View Controller 1 appears about a ~sec after the view displays.
Here is how I load calculationView in View Controller 2:
- (IBAction)startRunning:(id)sender {
NSLog(@"Start button pressed.");
helper = [[RunsDataHelper helper] init];
// Set this value to true so then other views also display the calculationsView
[helper setRunInProgres:YES];
// Add Calculations View Controller
CalculationViewController *calculationController = [self.storyboard instantiateViewControllerWithIdentifier:@"Calculate"];
[self addChildViewController:calculationController];
calculationController.view.frame = self.calculationView.bounds;
[UIView transitionWithView:self.calculationView
duration:0.4
options:UIViewAnimationOptionTransitionCurlDown
animations:^{
[self.calculationView addSubview:calculationController.view];
}
completion:nil];
[calculationController didMoveToParentViewController:self];
}
Here is how I use the runInProgress BOOL to display calculationView in View Controller 1:
-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
helper = [[RunsDataHelper helper] init];
if([helper runInProgres] == YES)
{
//Add Calculations View Controller
CalculationViewController *calculationController = [self.storyboard instantiateViewControllerWithIdentifier:@"Calculate"];
[self addChildViewController:calculationController];
calculationController.view.frame = self.calculationView.bounds;
[self.calculationView addSubview:calculationController.view];
[calculationController didMoveToParentViewController:self];
}
}
Questions:
Now my question is how can I make it so it the calculationView appears at the same time with the View Controller 1.
Also, I have a design question. the calculationView is going to be in a static place on every View Controller. Is there a better way to display calculationView on every view controller based on runInProgress BOOL.