gpt4 book ai didi

xamarin - 在 xamarin 形式中使用 Rg.Plugins.Popup 时出现异常

转载 作者:行者123 更新时间:2023-12-05 01:21:13 29 4
gpt4 key购买 nike

我在弹出窗口中填充了一个 ListView 。
我使用的是 1.0.4 版本

Rg.plugins.popup.

在选择列表项时,我打电话
PopupNavigation.PopAsync(true);

关闭弹出窗口。

但有时我会崩溃:
Android.Runtime.JavaProxyThrowable: Exception of type 'Android.Runtime.JavaProxyThrowable' was thrown. --- End of managed Android.Runtime.JavaProxyThrowable stack trace --- android.runtime.JavaProxyThrowable: System.IndexOutOfRangeException: There is not page in PopupStack at Rg.Plugins.Popup.Services.PopupNavigation.PopAsync (System.Boolean animate) [0x0000c] in :0 at TCRMobile.ViewModels.TicketsListGenericViewModel.OpenTicketTabsPage (TCRMobile.DataObjects.Ticket selectedTicket, System.Int32 mobileID, System.Nullable`1[T] laborMiscTimeMobileID) [0x00000] in :0 at TCRMobile.ViewModels.TicketsListGenericViewModel+<>c__DisplayClass13_0.b__0 () [0x00055] in :0 at TCRMobile.Droid.Services.DialogService+<>c__DisplayClass5_0.b__1 (System.Object sender, Android.Content.DialogClickEventArgs e) [0x0001d] in <5c6ae91b284846f5995b4e735df62b69>:0 at Android.Content.IDialogInterfaceOnClickListenerImplementor.OnClick (Android.Content.IDialogInterface dialog, System.Int32 which) [0x00012] in <1ccf2ea9504d42c08b47c05ee0c5e9f7>:0 at Android.Content.IDialogInterfaceOnClickListenerInvoker.n_OnClick_Landroid_content_DialogInterface_I (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_dialog, System.Int32 which) [0x0000f] in <1ccf2ea9504d42c08b47c05ee0c5e9f7>:0 at (wrapper dynamic-method) System.Object:d515a9d0-d793-4191-a5c6-5e450c1fd743 (intptr,intptr,intptr,int) at mono.android.content.DialogInterface_OnClickListenerImplementor.n_onClick(Native Method) at mono.android.content.DialogInterface_OnClickListenerImplementor.onClick(DialogInterface_OnClickListenerImplementor.java:30) at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:175) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6682) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1534) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1424)

我认为崩溃是因为我的一些用户双击了列表项。
我是否需要在调用之前始终检查弹出堆栈计数
popasync(true).

如果更新上面的弹出库可以解决这个问题?

请解释崩溃的原因和解决方案。

谢谢

最佳答案

试试这个弹出 View 页面。

  <?xml version="1.0" encoding="utf-8" ?>
<pages:PopupPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="RootNamespace.Views.NeedHelpPopupView"
xmlns:animations="clr-namespace:Rg.Plugins.Popup.Animations;assembly=Rg.Plugins.Popup"
xmlns:pages="clr-namespace:Rg.Plugins.Popup.Pages;assembly=Rg.Plugins.Popup"
xmlns:Controls="clr-namespace:RootNamespace.Controls">
<pages:PopupPage.Animation>
<animations:ScaleAnimation DurationIn="400" DurationOut="300" EasingIn="SinOut" EasingOut="SinIn" HasBackgroundAnimation="True" PositionIn="Center" PositionOut="Center" ScaleIn="1.2" ScaleOut="0.8" />
</pages:PopupPage.Animation>
<StackLayout Padding="20,20,20,20" HorizontalOptions="Center" VerticalOptions="Center">
<Grid Grid.Row="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Frame CornerRadius="10" Grid.Row="0" BackgroundColor="{StaticResource YetiBlue}" HasShadow="False" Margin="20,0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Image Source="{Binding IconNeedHelp}"/>
<Image Source="{Binding IconClose}" x:Name="ImageClose" HorizontalOptions="End" VerticalOptions="Start"/>
</Grid>
</Grid>
</Frame>
<Frame CornerRadius="10" Grid.Row="0" BackgroundColor="{StaticResource YetiBlue}" HasShadow="False" Margin="10,130,10,0">
</Frame>
<Frame CornerRadius="10" Grid.Row="0" BackgroundColor="{StaticResource White}" Margin="10,120,10,10" HasShadow="False">
<Grid BackgroundColor="{StaticResource White}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Controls:Label Grid.Row="0" Text="{Binding LabelNeedHelpTitle}" TextColor="{Binding Black}" HorizontalOptions="Center" FontAttributes="Bold" FontSize="20"/>
<BoxView Grid.Row="1" VerticalOptions="CenterAndExpand" HorizontalOptions="Center" WidthRequest="80" HeightRequest="4" Color="{StaticResource YetiBlue}"/>
<Controls:Label Grid.Row="2" Text="{Binding LabelDescription}" TextColor="{Binding Black}" HorizontalOptions="CenterAndExpand" FontAttributes="Bold" FontSize="17" Margin="{StaticResource Margin10}"/>
</Grid>
</Frame>
</Grid>
</StackLayout>
</pages:PopupPage>

这是导航部分。
 protected override void OnAppearing()
{
base.OnAppearing();
ImageClose.GestureRecognizers.Add(new TapGestureRecognizer
{
Command = new Command(_ =>
{
PopupNavigation.Instance.PopAsync();
})
});
}

安卓

在 MainActivity.cs 文件中。
Rg.Plugins.Popup.Popup.Init(this, bundle);

IOS

在 AppDelegate.cs 文件中。
 Rg.Plugins.Popup.Popup.Init();

试试这个代码。

并在项目 Rg.Plugins.Popup 1.1.4.158-pre 安装包。

关于xamarin - 在 xamarin 形式中使用 Rg.Plugins.Popup 时出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51828745/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com