Search code examples
iosobjective-canimationbackquartz-core

animate iphone screen on clicking back button


I am creating iPhone app where onclicking button I am going to another view controller with animation. below is what I have.

- (IBAction)booking:(id)sender {

    WebDetailsViewController *secondView = [self.storyboard instantiateViewControllerWithIdentifier:@"webDetailsEnglish"];

    secondView.fileType = @"web";
    secondView.myTitle  = @"Booking";
    secondView.fileName = @"http://almaktab.com/forms/flight.html";

    [UIView  beginAnimations: @"Showinfo"context: nil];
    [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:0.75];
    [self.navigationController pushViewController: secondView animated:NO];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
    [UIView commitAnimations];

}

I want to apply same animation effect when I click Back button on WebDetailsViewController.

Any idea how to get this done?


Solution

  • With the help of this SO Question below did trick...

    -(void) viewWillDisappear:(BOOL)animated {
        if ([self.navigationController.viewControllers indexOfObject:self]==NSNotFound) {
            [UIView  beginAnimations: @"Showinfo"context: nil];
            [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
            [UIView setAnimationDuration:0.75];
            [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
            [UIView commitAnimations];
    
        }
        [super viewWillDisappear:animated];
    }
    

    Thanks for all help...