Thursday, May 30, 2024
HomeiOS Developmentios - Maui utility throws UITableView error after navigating to sure pages

ios – Maui utility throws UITableView error after navigating to sure pages


I am presently creating a MAUI utility for Android and iOS. When deploying the app to an iOS machine – regardless if it is a simulator or an actual machine – there are just a few content material pages in my utility that may throw the next error when navigating to them:

enter image description here

Googling the difficulty has led me to consider that the error happens while you attempt to asynchronously fill or replace views that haven’t been drawn but. To be sincere, I did attempt to load information within the Showing occasion in my pages, however I already fastened that. Please take a look on the following pattern.
That is an instance of a web page known as StocktakingView and its view mannequin that may throw the error:

<ContentPage xmlns=...>
<ContentPage.Behaviors>
    <toolkit:EventToCommandBehavior EventName="Showing" Command="{Binding AppearingCommand}" />
    <toolkit:EventToCommandBehavior EventName="NavigatedFrom" Command="{Binding NavigatedFromCommand}" />
</ContentPage.Behaviors>
<ContentPage.ToolbarItems>
    <ToolbarItem Command="{Binding CreateCommand}" IconImageSource="{FontImageSource FontFamily=MaterialSharp, Glyph={x:Static m:MaterialSharp.Add}, Shade={AppThemeBinding Darkish=White, Gentle=Black}}" />
</ContentPage.ToolbarItems>
    <CollectionView ItemsSource="{Binding Stocktakings}">
        <CollectionView.ItemTemplate>
            <DataTemplate x:DataType="mannequin:Stocktaking">
                <Grid ColumnDefinitions="*,*" Padding="10">
                    <Grid.GestureRecognizers>
                        <TapGestureRecognizer Command="{Binding Supply={RelativeSource AncestorType={x:Kind vm:StocktakingViewModel}}, Path=TapCommand}" CommandParameter="{Binding .}" />
                    </Grid.GestureRecognizers>
                    <Label Grid.Column="0" Textual content="{Binding Identify}" FontAttributes="Daring" />
                    <Label Grid.Column="1" Textual content="{Binding Standing}" />
                </Grid>
            </DataTemplate>
        </CollectionView.ItemTemplate>
    </CollectionView>
</ContentPage>

And that is the view mannequin:

[QueryProperty("Stocktakings_list", "stocktakings")]
public partial class StocktakingViewModel : BaseViewModel
{
    personal readonly IUserDialogs _userDialogs;
    personal readonly IGenericService<Stocktaking, StocktakingCreationInfo> _stocktakingService;

    [ObservableProperty]
    Record<Stocktaking> stocktakings_list;

    [ObservableProperty]
    ObservableCollection<Stocktaking> stocktakings;

    public StocktakingViewModel(IUserDialogs userDialogs, IGenericService<Stocktaking, StocktakingCreationInfo> stocktakingService)
    {
        _userDialogs = userDialogs;
        _stocktakingService = stocktakingService;
    }

    [RelayCommand]
    personal void OnAppearing()
    {
        Stocktakings = new ObservableCollection<Stocktaking>(Stocktakings_list);
    }
...

Stocktakings is a listing of objects which get loaded by a HTTP request when tapping on a picture within the earlier web page. This occurs earlier than navigating to the Stocktaking web page. The record then will get handed as a parameter for the StocktakingView.

personal async Activity NavigateToStocktaking()
{
    Record<Stocktaking> stocktakings = await _stocktakingService.GetAll();

    Dictionary<string, object> param = new Dictionary<string, object>
    {
        { "stocktakings", stocktakings }
    };

    await Shell.Present.GoToAsync(nameof(StocktakingView), param);
}

There are different pages in my app which even have assortment views in them and which don’t throw any error. These views are additionally full of information earlier than navigating to the web page. There may be principally no distinction between these pages and the defective pages, but they don’t throw any error.

What I already tried:

  • Put the gathering view inside a grid
  • Change the gathering view to a listing view
  • Utterly do away with the gathering view, so that there’s nothing to attract
  • Eliminate the OnAppearing occasion fully

I am presently creating with Visible Studio 17.9.2 on a Home windows PC. I am linked to my Mac which has XCode 15.2 put in. I am additionally utilizing the Group MVVM toolkit.



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments