【问题标题】:MvvmCross - How to Add Custom Modal TransitionMvvmCross - 如何添加自定义模态转换
【发布时间】:2018-09-06 03:23:35
【问题描述】:

我正在使用 MvvmCross 和 Xamarin 开发一个项目。我试图在呈现和关闭我的模态视图时添加自定义过渡。目前我是这样介绍的:

[MvxModalPresentation(WrapInNavigationController = true, ModalPresentationStyle = UIModalPresentationStyle.Custom)]
public partial class MyView : MvxViewController
{

并以这种方式解雇它:

NavigationController.DismissModalViewController(true);

所以我已经准备好我的动画,但我假设我需要将转换委托设置为我创建的那个。我该怎么做?

我对 MvvmCross 还很陌生,因此非常感谢任何提示和技巧。谢谢!

【问题讨论】:

    标签: c# ios xamarin mvvm mvvmcross


    【解决方案1】:

    我不确定,你真正想要在这里实现什么。

    如果您正在寻找语法帮助。应该是这样的。

    this.NavigationController.TransitioningDelegate = new MyOwnDelegate();
    
    
      internal class MyOwnDelegate : IUIViewControllerTransitioningDelegate
        {
            public IntPtr Handle => throw new NotImplementedException();
    
            public void Dispose()
            {
                //throw new NotImplementedException();
            }
        }
    

    但通常人们使用,这个。如果有帮助,我也会给出一些语法

    this.NavigationController.Delegate = new NavigationControllerDelegate();
    
    
    
     public class NavigationControllerDelegate : UINavigationControllerDelegate
    {
        public NavigationControllerDelegate(IntPtr handle) : base(handle)
        {
        }
        public NavigationControllerDelegate()
        {
        }
        public override IUIViewControllerAnimatedTransitioning GetAnimationControllerForOperation(UINavigationController navigationController, UINavigationControllerOperation operation, UIViewController fromViewController, UIViewController toViewController)
        {
            var fromVcConformA = fromViewController as ICustomTransition;
            var fromVCConFromB = fromViewController as IWaterFallViewControllerProtocol;
            var fromVCCConformc = fromViewController as IHorizontalPageViewControllerProtocol;
    
            var toVcConformA = toViewController as ICustomTransition;
            var toVCConfromB = toViewController as IWaterFallViewControllerProtocol;
            var toVCCConformc = toViewController as IHorizontalPageViewControllerProtocol;
    
            if ((fromVcConformA != null) && (toVcConformA != null) && ((fromVCConFromB != null && toVCCConformc != null) || (fromVCCConformc != null && toVCConfromB != null)))
            {
                var transition = new CustomTransition();
                transition.presenting = operation == UINavigationControllerOperation.Pop;
                return transition;
            }
            else
            {
                return null;
            }
        }
    
    }
    

    【讨论】:

    • 我相信你已经回答了,但为了澄清,我问的是如何将转换委托应用于我的视图。我已经创建了一个委托和转换。
    • 感谢您的澄清,如果回答解决了问题,请采纳。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-23
    • 2010-10-16
    • 1970-01-01
    相关资源
    最近更新 更多