views:

943

answers:

2

I'm trying to get a basic flip animation transition working when I push a controller inside a navigation. The code below flips the view, however the view appears first (each element fades in), and then the flip occurs. Is it possible to do a flip animation with a UINavigationController?

Any pointers would be great, the examples I've found for Monotouch are performing animations on Views inside another view.

void ToolbarButtonClick()
{
    InformationController controller = new InformationController();
    NavigationController.PushViewController(controller,true);
}

public class InformationController : UIViewController
{
    public override void ViewDidLoad ()
    {
        UIView.BeginAnimations("Flip");
        UIView.SetAnimationDuration(1.0);
        UIView.SetAnimationTransition(UIViewAnimationTransition.FlipFromRight,View,true);

        base.ViewDidLoad ();
        Title = "Information";
    }

    public override void ViewWillAppear (bool animated)
    {
        base.ViewWillAppear (animated);
    }

    public override void ViewDidAppear (bool animated)
    {
        base.ViewDidAppear (animated);
        UIView.CommitAnimations();
    }
}
A: 

I'm not an expert, but I'm wondering about that TRUE on the PushViewcontroller which indicates that it is going to be animated. It has me wondering if that is making the NavigationController do the initial amount of animation work, which is then followed by yours. When you set it to false, what happens? I know we tend to automatically put the TRUE in there without thinking.

Driss Zouak
No animation happens at all if I remove the TRUE
Chris S
+1  A: 

I was sort of there, but the View needs to be taken from the NavigationController:

// Push the controller first or the Title doesn't animate
NavigationController.PushViewController(controller,false);

UIView.BeginAnimations(null,IntPtr.Zero);
UIView.SetAnimationDuration(1);  UIView.SetAnimationTransition(UIViewAnimationTransition.FlipFromLeft,NavigationController.View,true);
UIView.CommitAnimations();
Chris S