In my .NET8
MAUI
application, I use the MAUI CommunityToolkit
version 9.0.1. I have an issue with the Popup that crashes my app. I saw a bug on GitHub that is exactly my issue but there is no answer for it.
I defined my Popup view
<?xml version="1.0" encoding="utf-8" ?>
<toolkit:Popup
x:Class="LanguageInUse.Views.Popups.LoadingPopup"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:lang="clr-namespace:LanguageInUse"
xmlns:popups="clr-namespace:LanguageInUse.Views.Popups"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit">
<toolkit:Popup.Resources>
<Style TargetType="{x:Type popups:LoadingPopup}">
<Setter Property="Size" Value="300,300" />
<Setter Property="Color" Value="White" />
<Setter Property="HorizontalOptions" Value="Center" />
<Setter Property="VerticalOptions" Value="Center" />
<Setter Property="CanBeDismissedByTappingOutsideOfPopup" Value="False" />
</Style>
</toolkit:Popup.Resources>
<StackLayout
Margin="30"
HorizontalOptions="CenterAndExpand"
VerticalOptions="CenterAndExpand"
WidthRequest="350">
<VerticalStackLayout HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand">
<ActivityIndicator
HorizontalOptions="Center"
IsRunning="True"
Color="{StaticResource Gray900}" />
<Label
x:Name="labelLoading"
MaximumWidthRequest="240"
Style="{StaticResource labelLoading}"
Text="{lang:Translate Loading}"
WidthRequest="240" />
</VerticalStackLayout>
</StackLayout>
</toolkit:Popup>
When my app is in Release
mode and it displays the popup on iOS, I get this error
CommunityToolkit.Maui.Core.Views.MauiPopup.SetShadowView(UIView&
target)
CommunityToolkit.Maui.Core.Views.MauiPopup.ViewDidLayoutSubviews()
ObjCRuntime.Runtime.ThrowException(IntPtr )
UIKit.UIApplication.UIApplicationMain(Int32 , String[] , IntPtr ,
IntPtr ) UIKit.UIApplication.Main(String[] , Type , Type )
LanguageInUse.Program.Main(String[] args)
To display the Popup, I use this line
var loadingPopup = new LoadingPopup();
loadingPopup.SetMessage(AppResources.DictionaryWordsLoading);
loadingPopup.Opened += async (s, e) =>
{
try
{
// my code
}
catch (Exception ex)
{
}
finally
{
if (loadingPopup != null)
await loadingPopup.CloseAsync();
}
};
await Application.Current.MainPage.ShowPopupAsync(loadingPopup);
loadingPopup = null;
How can I fix it?