I am using this code to for flip transition.
MyViewController *viewController = [[MyViewController alloc] init];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:YES];
[self.navigationController pushViewController:viewController animated:NO];
[UIView commitAnimations];
[viewController release];
But instead of fliping from right, its flipping from top. My application works only in landscape mode.
Please help.
The animation constants have been defined with portrait mode in mind. If you define your application to be landscape mode only, you have to think about these animation constants with your head tilted 90 degrees.
Let's say your device's top is titled to the left, than you would set the animation with
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.navigationController.view cache:YES];
and it would curl from the right. That's because the bottom of the device faces to the right in this case.
The bad thing is that UIViewAnimationTransitionFlipFromBottom
is not defined. I guess you could rotate the coordinate system of the animation with 90 degrees, but I can't help you with that.
I don't know what Apple was thinking when they developed this API. Here's the workaround I used:
// Assume this code is in a view controller subclass
- (UIViewAnimationOptions)viewAnimationOptionTransitionFlipFromRight
{
switch (self.interfaceOrientation) {
case UIInterfaceOrientationPortrait:
return UIViewAnimationOptionTransitionFlipFromRight;
case UIInterfaceOrientationLandscapeLeft:
return UIViewAnimationOptionTransitionFlipFromBottom;
case UIInterfaceOrientationLandscapeRight:
return UIViewAnimationOptionTransitionFlipFromTop;
case UIInterfaceOrientationPortraitUpsideDown:
return UIViewAnimationOptionTransitionFlipFromLeft;
}
}
You can adjust the code accordingly if you want to flip in a different direction. If you want to use the page curl transitions, however, I'm afraid you may be completely out of luck.
来源:https://stackoverflow.com/questions/5262908/flip-transition-flips-view-from-top-in-landscape-mode