Reputation: 537
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:
The flip view transition should only change the view currently displayed within the top and bottom navigation bars.
Presenting the new view modally isn't an option because I will lose site of my navigation controller.
The view/view controller responsible for displaying the result set in a list format (i.e. UITableView) is contained within a single xib file where as the rest of the application sits within a storyboard.
Question
What is wrong with my current implementation? How should it be modified?
Upvotes: 0
Views: 855
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
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
Reputation: 339
Check this links may help you
how to implement an iPhone view transition animation with both flipping and scaling?
Hope it helps you . Thanks!!
Upvotes: 0