c# - 在推动页面停止移动时加载带有 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="" 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="" 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="" Size="45"></FontImageSource>
</NavigationPage.IconImageSource>
<x:Arguments>
<calendario_vistas:CalendarioLista></calendario_vistas:CalendarioLista>
</x:Arguments>
</NavigationPage>
</TabbedPage.Children>
</TabbedPage>
任何帮助表示赞赏。谢谢你。
PD:我刚刚意识到,如果我使用 ActivityIndicator,它会一直保持移动,不会停止。使用活动指示器,它可以完美运行。我只是不能让它不停地播放 gif。PD2:我在 Xamarin Forms 论坛上发布了两次,但没有得到任何答案 :(
解决方案
推荐阅读
- mysql - 在数据库中创建表时导致 SQL 语法错误的原因
- bash - 删除名称中带有 ^M 的文件夹
- python - 从客户端响应中提取请求的 HTML 页面的地址(Python3)
- node.js - 发送网格注册和登录问题
- c++ - 当我通过命令行编译时 unordered_map 无法识别,但代码块工作正常
- azure - 无法为嵌套 SharePoint 文件夹触发逻辑应用
- database - 如何访问项目 ID 以在列表视图 Xamarin 中为按钮编写命令
- c# - 如何在 MVC 5.2.3 中将 mvc 控制器继承到基本控制器
- async-await - 在 RxJS NextObserver 中使用异步方法
- azure - 将 rabbitmq 部署到 Azure