繁体   English   中英

Monotouch interactivePopGestureRecognizer和Navigation.popasync()空白视图

[英]Monotouch interactivePopGestureRecognizer and Navigation.popasync() blank view

我刚刚注意到使用interactivePopGestureRecognizer返回我的应用程序时的奇怪行为。

案例场景:

1)用户从左到右拖动视图他返回一个视图“interactivePopGestureRecognizer”。 2)用户向上或向下滑动“await Navigation.PopAsync(false);” 被调用,用户返回一个视图。 3)如果用户执行操作“1”然后调用新视图并尝试使用操作2返回,则显示空白视图。

仅当用户使用操作1然后尝试使用操作2时才会出现此错误; 如果从不使用动作1或仅使用动作1,则两者都可以正常应用。

我正在使用Xamarin.Forms并尝试使用“interactivePopGestureRecognizer.enabled = false”,但每次尝试都会出错。 两个后退导航之间有区别吗?

-------------更新----------

经过大量阅读并在互联网上查看后,我发现~interactivePopGestureRecognizer.enabled = false仅在您使用~ViewWillAppear内部时才有效。我创建了一个自定义渲染器,将其应用于我应用中的每个tableView。 我仍然想弄清楚为什么背部滑动这样做。

----更新2 ---只需按下后退按钮,然后尝试调用navigation.popasync也给我一个空白页面。 这似乎是Xamarin.Navigation和iOS后退功能之间的错误。

页:

MessagingCenter.Subscribe<string>(this, "UpSwipe", async (sender) =>
        {
            try
            {

                //await Navigation.PopAsync(false);
                Navigation.RemovePage(this);
            }
            catch (Exception e)
            { 
                await DisplayAlert("IsLoading", e.ToString(), "OK");
            }


        });

        MessagingCenter.Subscribe<string>(this, "DownSwipe", async (sender) =>
        {
            try
            {
                //await Navigation.PopAsync(false);
                Navigation.RemovePage(this);
            }
            catch (Exception e)
            { 
                await DisplayAlert("IsLoading", e.ToString(), "OK");
            }
        });

渲染:

private void UpdateUp()
    {
        // Insert view of DetailLeft element into subview
        // Add button to open Detail to parent navbar, if not yet there
        // Add gesture recognizer for left swipe
        //Console.WriteLine ("Left swipe");
        if (!buttons[2].Selected && !buttons[1].Selected)
        {

            MessagingCenter.Send("Swiped Up", "UpSwipe");

        }

    }

    private void UpdateDown()
    {
        // Insert view of DetailLeft element into subview
        // Add button to open Detail to parent navbar, if not yet there
        // Add gesture recognizer for left swipe
        //Console.WriteLine ("Left swipe");
        if (!buttons[2].Selected && !buttons[1].Selected)
        {
            MessagingCenter.Send("Swiped Down", "DownSwipe");
        }

    }

经过几个小时的调试后,我通过在渲染器中添加一个return语句来修复我的问题。 我正在检查并在我的渲染器中添加一些gestureRecognizers,因此在此错误发布之前不需要返回。

protected override void OnElementChanged (ElementChangedEventArgs<LRMasterDetailPage> e)
    {
        base.OnElementChanged (e);

        if (e.OldElement != null)
        {
            return;
        }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM