首页 > 解决方案 > 在推动页面停止移动时加载带有 gif 的弹出页面 - Xamarin Forms

问题描述

我正在尝试推送一个带有 3 个选项卡的 TabbedPage 页面,这些选项卡是带有 SfSchedule 的页面(一个需要一些加载的 SyncFusion 控件)。因为加载需要很长时间,我正在使用 Rg.Plugins.Popup 插件来推送带有 GIF 的模态页面(一些字符移动)。问题是,当 TabbedPage 被推送时,gif 停止移动,一旦加载它就会继续移动。我试图使用另一个线程来实例化页面,但因为我最终必须使用 Device.BeginInvokeOnMainThread 来推送页面,它无论如何都会阻止 gif 移动。此外,我必须在另一个线程中实例化页面,然后使用 Device.BeginInvokeOnMainThread 推送它,而需要时间的是推送页面,而不是实例化它。

推送页面和Popup的方法:

public async void Navegar(Type page)
        {
            _tipoPagina = page;
            await Rg.Plugins.Popup.Services.PopupNavigation.Instance.PushAsync(new LoadingPopUp());
            var pagina = (Page)Activator.CreateInstance(_tipoPagina);
            await ((NavigationPage)this.Detail).PushAsync(pagina);
            await Rg.Plugins.Popup.Services.PopupNavigation.Instance.PopAllAsync();
        }

弹出页面:

<?xml version="1.0" encoding="utf-8" ?>
<pages:PopupPage
        xmlns:pages="clr-namespace:Rg.Plugins.Popup.Pages;assembly=Rg.Plugins.Popup"
        xmlns="http://xamarin.com/schemas/2014/forms"
        xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
        xmlns:d="http://xamarin.com/schemas/2014/forms/design"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        x:Class="XXXXX.LoadingPopUp">
    <StackLayout HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" BackgroundColor="White">
        <Image VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand" Source="loading.gif" IsAnimationPlaying="True"></Image>
    </StackLayout>
</pages:PopupPage>

推送时间长的Page:

<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:d="http://xamarin.com/schemas/2014/forms/design"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
            xmlns:plugin="clr-namespace:Plugin.Badge.Abstractions;assembly=Plugin.Badge.Abstractions"
            xmlns:calendario_vistas="clr-namespace:XXXXX.Calendario_Vistas"
            mc:Ignorable="d"
            x:Class="XXXXX.Calendario"
            Title="Calendario"
            NavigationPage.HasNavigationBar="False">
    <TabbedPage.Children>
        <NavigationPage Title="Día">
            <NavigationPage.IconImageSource>
                <FontImageSource FontFamily="{StaticResource FASolido}" Glyph="&#xf783;" Size="45"></FontImageSource>
            </NavigationPage.IconImageSource>
            <x:Arguments>
                <calendario_vistas:CalendarioDiario plugin:TabBadge.BadgeText="3"></calendario_vistas:CalendarioDiario>
            </x:Arguments>
        </NavigationPage>
        <NavigationPage Title="Semanal">
            <NavigationPage.IconImageSource>
                <FontImageSource FontFamily="{StaticResource FASolido}" Glyph="&#xf784;" Size="45"></FontImageSource>
            </NavigationPage.IconImageSource>
            <x:Arguments>
                <calendario_vistas:CalendarioSemanal plugin:TabBadge.BadgeText="10"></calendario_vistas:CalendarioSemanal>
            </x:Arguments>
        </NavigationPage>
        <NavigationPage Title="Listado">
            <NavigationPage.IconImageSource>
                <FontImageSource FontFamily="{StaticResource FASolido}" Glyph="&#xf073;" Size="45"></FontImageSource>
            </NavigationPage.IconImageSource>
            <x:Arguments>
                <calendario_vistas:CalendarioLista></calendario_vistas:CalendarioLista>
            </x:Arguments>
        </NavigationPage>
    </TabbedPage.Children>
</TabbedPage>

任何帮助表示赞赏。谢谢你。

PD:我刚刚意识到,如果我使用 ActivityIndi​​cator,它会一直保持移动,不会停止。使用活动指示器,它可以完美运行。我只是不能让它不停地播放 gif。PD2:我在 Xamarin Forms 论坛上发布了两次,但没有得到任何答案 :(

标签: c#xamarinxamarin.forms

解决方案


推荐阅读