0

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: enter image description here

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.

Archon
  • 182
  • 9
  • have you tried changing your code from `(void) viewDidAppear:(BOOL)animated` to `(void) viewWillAppear:(BOOL) animated`? – Ares Apr 14 '13 at 23:40
  • If I use viewWillAppear I run into the problem described in my other thread **[here](http://stackoverflow.com/questions/15916116/ios-presenting-a-uiviewcontroller-inside-anther-uiviewcontroller)**. But I've noticed once I start switching between tabs the view appears just fine and its instant too. – Archon Apr 15 '13 at 04:59

0 Answers0