【问题标题】:Swipe right on Xamarin.iOS with IOS 13 doesn't animate the effect使用 IOS 13 在 Xamarin.iOS 上向右滑动不会动画效果
【发布时间】:2020-04-06 17:52:30
【问题描述】:

我有 Xamarin Native (iOS/Droid) 应用程序。在较旧的 iOS 版本中,可以通过向右滑动一个拖动屏幕当前视图的动画来导航回以前的 viewController。更新到最新的 iOS 13 后,此动画不再出现。 ViewWillDissapper 也不会被调用。 我错过了什么?

我已经尝试过这些更改:

this.ModalInPresentation = true;
this.ModalPresentationStyle = UIModalPresentationStyle.FullScreen;
NavigationController.InteractivePopGestureRecognizer.Enabled = true;
NavigationController.InteractivePopGestureRecognizer.Delegate = new MyGestureDelegate();

【问题讨论】:

    标签: ios xamarin.ios ios13


    【解决方案1】:

    在 iOS 13 中,您可以在 previous ViewController 中进行如下设置:

    UIViewControllerSecond viewControllerSecond = new UIViewControllerSecond();
    viewControllerSecond.ModalPresentationStyle = UIModalPresentationStyle.FullScreen;
    viewControllerSecond.ModalTransitionStyle = UIModalTransitionStyle.FlipHorizontal;
    PresentViewController(viewControllerSecond, true, null);
    

    然后在 第二个 ViewController 返回时只需 DismissModalViewController(true);

    UISwipeGestureRecognizer swipeGesture = new UISwipeGestureRecognizer();
    swipeGesture.Direction = UISwipeGestureRecognizerDirection.Right;
    swipeGesture.AddTarget(() => { Console.WriteLine("-swipe-to-right-"); DismissViewController(true, null); });
    View.AddGestureRecognizer(swipeGesture);
    

    看看这个效果,是否需要。

    【讨论】:

    • 谢谢,但它没有用,似乎带有 IO 13 的 Xamarin 使用dismissViewController() 没有做任何事情
    • 嗨,我在 iOS 13 中测试过,它可以工作。您可以在两个视图控制器之间共享有关导航的完整代码。
    • 再次嗨,我知道它适用于 iOS 13,问题是我正在使用 Xamarin,它适用于 Viewmodels,这些会启动视图控制器,我不使用 presentViewController 方法,因为它将失去多平台方面。 iOS 让他们关闭一个 viewController 的唯一方法是使用 NavigationController.PopViewController(animated);
    • @AdriaAlabau 这取决于如何导航到下一个控制器(模型导航/ NavigationControll 导航)。如果使用 NavigationController.PushViewController(new UIViewControllerSecond(), true); 那么你可以使用 NavigationController.PopViewController(animated) 。但是,在这里我使用PresentViewController(viewControllerSecond, true, null);PresentModalViewController(new UIViewControllerSecond(), true); 然后我可以DismissViewController(true, null);。对此进行检查是否有效。
    【解决方案2】:

    该应用正在使用 Xamarin Native 和 Mvvm Cross。原来4.4版的mvvm交叉包不支持iOS 13,更新到5.7解决了我的问题

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-08-09
      • 2017-04-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多