【问题标题】:Activity Indicator Stuck while Navigating in xamarin forms在 xamarin 表单中导航时活动指示器卡住
【发布时间】:2017-06-25 12:53:55
【问题描述】:

Im using xamarin forms 2.3.4.247 shared project. In my login page im navigating my page to another. while this page is rendering im 在主页中显示活动指示器。但不幸的是,活动指示器卡住了,几秒钟后第二个页面加载。ive tried these codes below and i got nothing.All of these codes are running into an async command.im 在 android 平台上的实际设备中测试我的应用程序。

1

activityIndicator.IsRunnig=true;
    new System.Threading.Thread(new System.Threading.ThreadStart(() =>
                        {
                            Navigation.PushAsync(new DeviceLoginView());
                        })).Start();

2

activityIndicator.IsRunnig=true;
Device.BeginInvokeOnMainThread(async () =>
                {
                    await Navigation.PushAsync(new DeviceLoginView());
                });

3

 activityIndicator.IsRunnig=true;
 await Navigation.PushAsync(new DeviceLoginView());

【问题讨论】:

    标签: xamarin navigation xamarin.android xamarin.forms activity-indicator


    【解决方案1】:

    这个问题是因为您的活动指示器在旧页面的 UI 中而不是在新页面上,所以当您执行推送时,旧页面不再显示。 为了获得您想要的结果,您可以使用此插件在过渡期间保持加载 https://github.com/aritchie/userdialogs

    【讨论】:

      【解决方案2】:

      我终于能够解决这个问题。 您可以在 Task.Run() 方法中执行所有异步作业,以在新线程中而不是在 UI 线程中运行所有这些作业

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-12-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-12-05
        相关资源
        最近更新 更多