菜鸟教程小白 发表于 2022-12-11 20:33:19

c# - MvvmCross - 如何添加自定义模态转换


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

<pre><code>
public partial class MyView : MvxViewController
{
</code></pre>

<p>并以这种方式解雇它:</p>

<pre><code>NavigationController.DismissModalViewController(true);
</code></pre>

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

<p>我对 MvvmCross 还很陌生,因此非常感谢任何提示和技巧。谢谢!</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>我不确定,你真正想要在这里实现什么。</p>

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

<pre><code>this.NavigationController.TransitioningDelegate = new MyOwnDelegate();


internal class MyOwnDelegate : IUIViewControllerTransitioningDelegate
    {
      public IntPtr Handle =&gt; throw new NotImplementedException();

      public void Dispose()
      {
            //throw new NotImplementedException();
      }
    }
</code></pre>

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

<pre><code>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) &amp;&amp; (toVcConformA != null) &amp;&amp; ((fromVCConFromB != null &amp;&amp; toVCCConformc != null) || (fromVCCConformc != null &amp;&amp; toVCConfromB != null)))
      {
            var transition = new CustomTransition();
            transition.presenting = operation == UINavigationControllerOperation.Pop;
            return transition;
      }
      else
      {
            return null;
      }
    }

}
</code></pre></p>
                                   
                                                <p style="font-size: 20px;">关于c# - MvvmCross - 如何添加自定义模态转换,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/52196061/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/52196061/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: c# - MvvmCross - 如何添加自定义模态转换