AiForms.Maui.SettingsView icon indicating copy to clipboard operation
AiForms.Maui.SettingsView copied to clipboard

iOS: App is crashing when using a CarouselView/CollectionView with AISettingsView

Open rdelrosario opened this issue 3 months ago • 0 comments

Description

When using a CarouselView or a CollectionView it crashes because of this exception:

System.NullReferenceException: Object reference not set to an instance of an object. at AiForms.Settings.Handlers.SettingsViewHandler.CreatePlatformView() at Microsoft.Maui.Handlers.ViewHandler`2[[AiForms.Settings.SettingsView, SettingsView, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[AiForms.Settings.Platforms.iOS.AiTableView, SettingsView, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].OnCreatePlatformView() at Microsoft.Maui.Handlers.ViewHandler.OnCreatePlatformElement()

The issue is happening because when calling the CreatePlatformView() the Parent is null (for this scenario it gets set later), this specific code is causing the crash: _parentPage.Appearing += ParentPageAppearing

Steps to Reproduce

  1. Create an app with a CarouselView or CollectionView and add the AISettingsView in the content

Actual Behavior

The app is crashing

Platforms

  • [ ] Android
  • [x ] iOS

Basic Information

  • AiForms.SettingsView 1.0.8
  • MAUI 8.0.14
  • Affected Devices: All iOS devices

Reproduction Link

https://drive.google.com/file/d/15qU2K2TQsK20s-t10FoPRyLFVwnLM-_r/view?usp=sharing

Workaround

If you manually set the Parent in the xaml, it won't crash. For example:

 <CarouselView x:Name="CarouselView">
        <CarouselView.ItemTemplate>
            <DataTemplate>
              <sv:SettingsView HasUnevenRows="true"
                               Parent="CarouselView">
              </sv:SettingsView>
            </DataTemplate>
          </CarouselView.ItemTemplate>
    </CarouselView>

rdelrosario avatar Mar 23 '24 00:03 rdelrosario