horizontal flip animation on modal UIView - iphone

how can i present a modal view with an horizontal flip animation (like pushing an view controller on a navigation controller) ?
i tried this but it doesn't work
[UIView beginAnimations:#"animation" context:nil];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:NO];
[self presentModalViewController:detailsViewController animated:NO];
[UIView commitAnimations];
thanks !

This is all you need:
detailsViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:detailsViewController animated:YES];

Related

iphone dev: how to control the view transition animation?

I am using such code to present a new view, I don't it's good or not. Currently the default animation is show the view from bottom up, but i want it to animate from right to left(fly in), is it possible to change the default animation type and how? Thanks.
[self presentModalViewController:navController animated:animated];
You can disable the slide-up animation like this:
[self presentModalViewController:navController animated:NO];
Then you can provide your own animation code:
navController.view.frame = CGRectMake(320, 0, navController.view.frame.size.width, navController.view.frame.size.height);
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
navController.view.frame = CGRectMake(0, 0, navController.view.frame.size.width, navController.view.frame.size.height);
[UIView commitAnimations];
This example gives you the "Fly-in" from right with a smooth speed-curve.
Another way is using the built in slide-in from right with navigationcontroller:
[self.navigationController pushViewController:navController animated:YES];
In this one, your top-viewcontroller needs to be a UINavigationController and it's rootcontroller needs to be your viewcontroller. Then you can push other viewcontrollers.
I have done this and its working for me try ths:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.6];
[UIView setAnimationDelegate:self];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.View2.superview cache:YES];
[self.View2 removeFromSuperview];
[self performSelector:#selector(replaceViews2) withObject:nil afterDelay:0.6];
[UIView commitAnimations];

UIView animation transition between views

I need to make an animation that will come in from the right, displaying the new view.
[UIView beginAnimations:nil context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDelay:.5f];
[UIView setAnimationDuration:0.5f];
// display view controller
[UIView commitAnimations];
What should I add here??
IF you have navigationController then use
NextViewcontroller *nextView = [NextViewcontroller alloc]initWithNibName#"NextViewcontroller"
bundle:nil];
[self.navigationController pushViewcontroller:nextView animated:YES];
[nextView release];
How about adding the view as a subView to your current view, then set its place to be outside the current visible area. After which you set your animation to change your subViews position to overlap the current view.

how to go one view from another view using with flip animation in iPhone

I am flip animation to go from one view to another and animation is working properly but when i am using button action on that view that time application is getting crash.
Please help me out to solve this problem.
my code is:
Abtsk1 *secondViewController = [[Abtsk1 alloc]
initWithNibName:#"Abtsk1"
bundle:nil];
[UIView beginAnimations:#"flipping view" context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown
forView:[[self navigationController] view] cache:YES];
[self.view addSubview:secondViewController.view];
[UIView commitAnimations];
Thanks
Kunal

popViewController doesnt seem to work with UIView animations

I have the following code, which does a nice animation when pushing a new view controller.
[UIView beginAnimations:#"animation" context:nil];
[UIView setAnimationDuration:0.5];
[[self navigationController] pushViewController:details animated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
[UIView commitAnimations];
This code, using popViewController (rather than pushViewController) doesnt do the animation.
[UIView beginAnimations:#"animationback" context:nil];
[UIView setAnimationDuration:0.5];
[[self navigationController] popViewControllerAnimated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
[UIView commitAnimations];
Any ideas why this would be and more importantly; how can I fix it?
Are you sure that self.navigationController.view really refers to the right view ... the one being animated? I have the feeling that the first case works only by accident. Shouldn't you refer to the view of the controller being pushed / popped?

Flip animation when controller pushed on iPhone

I had a look around and didn't find what I was exactly looking for.
Is there a way to get a flip animation when pushing a view controller?
I read that you can change the animation by using a modal view controller but AFAIK the animation for a modal view is from bottom to top and that's not what i am looking for. Is there a way to get a flip animation somehow?
something like this should work
[UIView beginAnimations:#"animation" context:nil];
[self.navigationController pushViewController: yourviewcontroller animated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
[UIView commitAnimations];
don't forget to set animated to NO when calling pushViewController
This also works.. for iOS 4.0 and greater
[UIView transitionWithView:self.navigationController.view duration:0.8 options:UIViewAnimationOptionTransitionFlipFromLeft
animations:^(void) {
BOOL oldState = [UIView areAnimationsEnabled];
[UIView setAnimationsEnabled:NO];
[self.navigationController pushViewController:viewController animated:YES];
[UIView setAnimationsEnabled:oldState];
}
completion:nil];
- (void)viewWillDisappear:(BOOL)animated {
[UIView beginAnimations:#"animation2" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration: 0.7];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
[UIView commitAnimations]; }
in the new viewcontroller will make it flip back the same way (instead of sliding left) when the back button in the toolbar is pushed -- make sure animation is enabled here, e.g., if you make a custom button to pop the stack, use:
- (void) backToPrevious: (id) sender
{
//[self.navigationController popViewControllerAnimated:YES];
[self dismissModalViewControllerAnimated:YES];
}
For modally presented view controllers, you can change the animation with the modalTransitionStyle property. AFAIK, there is no way to change a navigation controller's push animation (except rebuilding UINavigationController from scratch).