3

I load a view controller in my code using a segue in UIStoryboard. Based on a few user selected options, I then hide or show a UI control using an animation. It all works fine.

- (void)showComments {
    NSLog(@"Show Comments");
    _commentsTextView.hidden = NO;
    _commentsTextView.frame = CGRectMake(435, 266, 475, 134);

    [UIView animateWithDuration:1 animations:^{
        _commentsTextView.alpha = 1;
        _signatureButton.frame = CGRectMake(435, 420, 475, 134);
        _cancelButton.frame = CGRectMake(568, 581, 100, 44);
        _finishedButton.frame = CGRectMake(676, 581, 100, 44);
    }];

}

Then I am presenting a view controller created in UIStoryboard using the following code:

    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPad" bundle:nil];

    SigningViewController *signingVC = (SigningViewController *)[storyboard instantiateViewControllerWithIdentifier:@"SigningViewController"];
    signingVC.object = self;
    signingVC.signatureProperty = @"employeeSignature";
    signingVC.startDate = self.startDate;
    signingVC.endDate = self.endDate;

    [self presentViewController:signingVC animated:YES completion:nil];

When this code fires all happens as expected except for one thing: All the custom animations that hid or showed a UI control revert back. It is as if by calling the presentViewController method, it is redrawing my existing view from the UIStoryboard.

Is there a way to get it to quit redrawing/reload my existing view from the Storyboard before displaying the new view modally?

ddorrity
  • 96
  • 5

2 Answers2

0

I had the same problem too. Whatever I tried to make an animation change whenever a modal closed it seemed to reset back to the original storyboard.

The solution I had to go with was to add any animation view as an outlet to the header file. Take off the view out of the self.view or main view of the view controller on the storyboard and programmatically add it as a subview. Set the frame to where you want it and all the animation positions should be the same after you end the modal. It worked for me if you need more explanation and let me know.

Michael Choi
  • 285
  • 1
  • 3
  • 15
0

I had just the same problem and posted it here in a more detailed form, A user named kokx helped me a lot and the answer is documented in my question page.

Community
  • 1
  • 1
Itamar
  • 1,290
  • 1
  • 18
  • 29