I am working on a .net maui project involving the need to dive into native code to fix a well-known issue with the collection views not resizing when, say, expanding a section in a custom accordion on ios (surprise surprise).
I am stuck on getting each section item in a UICollectionView to reload when data has been updated so that the cell size can correctly update when data changes. Here is the code that I have so far for the OnItemSelected command when selecting an item in the ollection view MAUI control:
public void OnSectionTapped(ItemObject section)
{
section.Expanded = !section.Expanded;
#if IOS
var baseView = MainCollectionView.Handler.PlatformView;
if(baseView != null)
{
var view = baseView as UIView;
if(view != null)
{
var subViewItemIsCollecitonView = view.Subviews[0] is UICollectionView;
if(subViewItemIsCollecitonView)
{
var iosCollectionView = (view.Subviews[0] as UICollectionView);
// This is the section where I am stuck
var items = iosCollectionView.GetIndexPathsForSelectedItems();
if(items != null)
{
var itemArr = items.ToArray();
var item = itemArr.FirstOrDefault();
//iosCollectionView.ReloadItems(items.ToArray());
//This is the section where I am stuck
}
}
}
}
#endif
}
I’ve looked at the iOS docs, but I guess I’m having a hard time wrapping my head around getting the section and item indexes for the IndexPath to reload each item. I do apologize for the stupid question sinc this is my first time having to do this. Thanks.