当前位置: 动力学知识库 > 问答 > 编程问答 >

xamarin.ios - Change the navigation to come from bottom to top in MvvmCross in iOS + Xamarin

问题描述:

I am using MvvmCross and using ShowViewModel to navigate between view. It takes the default navigation behavior i.e., slides from Right->Left . I want few view controllers to slide from bottom to top . Can someone let me know how we can do this in MvvmCross. These are not overlays but regular view controllers.

网友答案:

You can achieve this by setting a custom delegate for your Navigation Controller. This can be done by override following method in your custom ViewPresenter

protected override void OnMasterNavigationControllerCreated()
{
    this.MasterNavigationController.WeakDelegate = new NavigationControllerDelegate();
}

Within this delegate you can set your transitions, e.g.:

public class NavigationControllerDelegate : UINavigationControllerDelegate
{
    public override IUIViewControllerAnimatedTransitioning GetAnimationControllerForOperation(UINavigationController navigationController, UINavigationControllerOperation operation, UIViewController fromViewController, UIViewController toViewController)
    {
        if (operation == UINavigationControllerOperation.Push)
        {
            if (fromViewController is MenuViewController)
            {
                return new BottomToTopTransition();
            }

            ...

        }
    }
}

BottomToTopTransition is also a custom class and inherits from UIViewControllerAnimatedTransitioning. Last step is to override AnimateTransition() in this transition class and you are done.

分享给朋友:
您可能感兴趣的文章:
随机阅读: