Question

i try to build a app that is in landsscape mode all the time. I did the usual stuff: plist added UIInterfaceOrientation / UIInterfaceOrientationLandscapeRight rotated the XIBs in interface builder with the little arrow in top of view.

my code for launching:
- (void)applicationDidFinishLaunching:(UIApplication *)application {    
        [[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];
    FlipViewController *flip = [[FlipViewController alloc] initWithNibName:@"FlipViewController" bundle:nil];
    [window addSubview:flip.view];
    [window makeKeyAndVisible];
}

But when i try to do a "UIViewAnimationTransitionFlipFromLeft" the page flips from top to bottom instead of right to left. :-/

This is the code i use to flip the views:

[UIView beginAnimations:@"View Flip" context:nil];
    [UIView setAnimationDuration:1.25];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

    UIViewController *coming = nil;
    UIViewController *going = nil;
    UIViewAnimationTransition transition;

    if (self.blueViewController.view.superview == nil) 
    {   
        coming = blueViewController;
        going = yellowViewController;
        transition = UIViewAnimationTransitionFlipFromLeft;
    }
    else
    {
        coming = yellowViewController;
        going = blueViewController;
        transition = UIViewAnimationTransitionFlipFromRight;
    }

    [UIView setAnimationTransition: transition forView:self.view cache:YES];
    [coming viewWillAppear:YES];
    [going viewWillDisappear:YES];
    [going.view removeFromSuperview];
    [self.view insertSubview: coming.view atIndex:0];
    [going viewDidDisappear:YES];
    [coming viewDidAppear:YES];

    [UIView commitAnimations];

"window" seems to have missed the fact, that it is in landsscape-mode. Hmmm. can anyone spot my mistake?

Was it helpful?

Solution

Not possible with documented methods.

You need to use CATransition. (CATransition itself is documented, but the flip transition is not.)

To use the flip transition, set the transition's type to "oglFlip" and set subtype to fromLeft/Top/Right/Bottom.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top