在xamarin表单中使用Rg.Plugins.Popup时出现异常
我在弹出窗口中填充了一个列表视图。 我使用的是1.0.4版本的在xamarin表单中使用Rg.Plugins.Popup时出现异常,xamarin,xamarin.forms,android-popupwindow,Xamarin,Xamarin.forms,Android Popupwindow,我在弹出窗口中填充了一个列表视图。 我使用的是1.0.4版本的 Rg.plugins.popup. 在选择列表项时,我正在呼叫 PopupNavigation.PopAsync(true); 关闭弹出窗口 但有时我会在崩溃中崩溃: Android.Runtime.JavaProxyThrowable: Exception of type 'Android.Runtime.JavaProxyThrowable' was thrown. --- End of managed Android.Ru
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)
更新上述弹出库是否可以解决此问题
请解释崩溃的原因和解决方案
谢谢尝试此弹出视图页面
<?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>
Android
在MainActivity.cs文件中
Rg.Plugins.Popup.Popup.Init(this, bundle);
IOS
在AppDelegate.cs文件中
Rg.Plugins.Popup.Popup.Init();
尝试删除此代码
并且在Project中安装了Rg.Plugins.Popup 1.1.4.158-pre软件包。这可能是一个更简单的解决方案 叫它
await PopUpService.PopUpAll();
服务
public static class PopUpService
{
public static async Task PopUpAll()
{
if (Rg.Plugins.Popup.Services.PopupNavigation.Instance.PopupStack.Any())
{
await Rg.Plugins.Popup.Services.PopupNavigation.Instance.PopAllAsync();
}
}
}
只需使用一个按钮;作为参考,如果用户单击,clicked=true并检查用户是否已经检查,然后返回;尝试在if(PopupNavigation.PopupStack?.Any())之前写入,因此更新此插件并在app delegate中添加上述行,它是快速关闭弹出窗口还是检查堆栈中是否没有弹出窗口?请更改动画速度。我的持续时间是100@Limbani Akash
await PopUpService.PopUpAll();
public static class PopUpService
{
public static async Task PopUpAll()
{
if (Rg.Plugins.Popup.Services.PopupNavigation.Instance.PopupStack.Any())
{
await Rg.Plugins.Popup.Services.PopupNavigation.Instance.PopAllAsync();
}
}
}