Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Do you have a containerView? Something that can be there so you can add and remove subviews from it? Animation can break if you have two viewControllers, one coming and one going, without a containerView. I use a rootViewController and animate all my pages to and from each other with the rootViewcontroller in the back. Here is my code for flipping, you'll probably have to do a little editing to make it work for you:</p> <p>(keep in mind that self is the rootViewcontroller, a viewcontroller with a blank view (color it so it matches your views))</p> <pre><code>- (void)switchTwoViews:(UIViewController *)view1 otherView:(UIViewController *)view2 { /* This method is called to switch views. It flips the displayed view from the main view to the flipside view and vice-versa. */ UIViewController *coming = nil; UIViewController *going = nil; UIViewAnimationTransition transition; [view1.view setUserInteractionEnabled: NO]; [view2.view setUserInteractionEnabled: NO]; if (view1.view.superview == nil) { coming = view1; going = view2; transition = UIViewAnimationTransitionFlipFromLeft; } else { coming = view2; going = view1; transition = UIViewAnimationTransitionFlipFromRight; } // in some cases the following is needed to size the view // coming.view.frame = [UIScreen mainScreen].applicationFrame; // going.view.alpha = 1.0; //uncomment these lines if we want fading of views // coming.view.alpha = 0.0; NSArray *viewArray = [[NSArray alloc] initWithObjects:coming, going, nil]; [coming viewWillAppear:YES]; [going viewWillDisappear:YES]; [UIView beginAnimations:@"View Flip" context:viewArray]; { [UIView setAnimationDuration:1.0]; [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(animationDidEnd:finished:context:)]; [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; // coming.view.alpha = 1.0; //uncomment these lines if we want fading of views // going.view.alpha = 0.0; [UIView setAnimationTransition:transition forView:self.view cache:YES]; [self.view addSubview: coming.view]; } [UIView commitAnimations]; } - (void) animationDidEnd:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context { NSArray *viewArray = context; [((UIViewController *)[viewArray objectAtIndex:1]).view removeFromSuperview]; [[viewArray objectAtIndex:1] viewDidDisappear:YES]; [[viewArray objectAtIndex:0] viewDidAppear:YES]; [[[viewArray objectAtIndex:0] view] setUserInteractionEnabled: YES]; [viewArray release]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload