开发者

BeginAnimations and CommitAnimations with NavigationController.PushViewController

开发者 https://www.devze.com 2022-12-24 04:44 出处:网络
I\'m trying to get a basic flip animation transition working when I push a controller inside a navigation. The code below fli开发者_开发问答ps the view, however the view appears first (each element fa

I'm trying to get a basic flip animation transition working when I push a controller inside a navigation. The code below fli开发者_开发问答ps 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();
    }
}


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();


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号