dpalmajr
dpalmajr

Reputation: 537

FlipView Transition

I'm currently designing an app that pulls map data from a service and renders them as pins on the MKMapView. In addition, my application has been designed using storyboards where each scene is embedded within a navigation controller. The feature I'm working on requires me to give the user the ability to toggle between a map view and table view for a given result set. To provide this functionality I've included a bar button item in the toolBar which (when pressed) should flip the current view out and a second view in.

So far I've been trying to the following code but to no avail:

MapListViewController *map = [[MapListViewController alloc]init];
[UIView beginAnimations:@"flip animation" context:nil];
[UIView setAnimationDuration:3.0];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:map.view cache:YES];

[self.mapView removeFromSuperview];
[self.view addSubview:map.view];
[UIView commitAnimations];

I originally got this approach from here but it doesn't seem to be working for me.

A couple more things to note:

Question

What is wrong with my current implementation? How should it be modified?

Upvotes: 0

Views: 855

Answers (3)

HM1
HM1

Reputation: 1684

I haven't used your method but I did implement flipping some views using a UIView class method. It was very easy and straightforward. Refer to the docs for other options.

[UIView transitionFromView:self.firstVC.view toView:self.secondVC.view duration:1.0 options:UIViewAnimationOptionTransitionFlipFromLeft completion:^(BOOL finished) {
    // add any completion code here if needed.
}];

Upvotes: 3

J S Rodrigues
J S Rodrigues

Reputation: 471

Hi implementing some thing like this should help you

To Push use this..

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1];
    [navigationController pushViewController:viewController animated:NO];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:navigationController.view cache:NO];
    [UIView commitAnimations];

For Pop use this

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1];
    [navigationController popViewControllerAnimated:NO];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:navigationController.view cache:NO];
    [UIView commitAnimations];

Upvotes: 0

Kiran
Kiran

Reputation: 339

Check this links may help you

Flip View Iphone

how to implement an iPhone view transition animation with both flipping and scaling?

Hope it helps you . Thanks!!

Upvotes: 0

Related Questions