CollectionView ShowModal Problem

Hi,

I am having a problem displaying a collection view modally.

Please see example: http://www.estateagentpro.com/iCL%20CollectionView%20Bug.zip

If you click on the button on the main screen and then the back button on the dialog and repeat this after a few times the app crashes.

If I remove the collection view from the dialog this does not happen.

Ken

Hi, 


We have investigated this here and have applied a fix for this.
The next version will address this issue. You can already try it out by adding the red line in the destroy sequence of the collectionview component:

  if Assigned(FCollectionView) then
  begin
    FCollectionView.removeFromSuperview;
    FCollectionView.release;
    FCollectionView := nil;
  end;

Kind Regards, 
Pieter

Thanks, I will come back and confirm.

I'm afraid that this does not cure the problem and still occurs after doing it a few times.

Just to confirm. I have modified:

destructor TTMSFMXNativeUICollectionView.Destroy;
...
  if Assigned(FCollectionView) then
  begin
    FCollectionView.removeFromSuperview;
    FCollectionView.release;
    FCollectionView := nil;
  end;
...

Interestingly enough if, instead of creating the collection view at design time, I create it programatically in the forms OnCreate event and dispose of it in the forms destructor I don't have the same problem even without the new line of code provided.

We have tested this here in the simulator. We will test it again on the device.

Is it a consistent amount of create/destroy sequences?

Kind Regards, 
Pieter

Thanks, yes, it is. I am using a device and it happens every time.

Sorry, I did not reply fully, sometimes it happens the 3rd time it's opened and others the 2nd time.

Is there any news on this as it is rather a show stopper for me? The good news is that this does not happen with a table view!

Hi, 


We are still investigating this here, but creating a modal form for native iCL controls is currently not supported and could be the reason why the UICollectionView crashes. the correct way to display a viewcontroller is to display it from the rootviewcontroller with the presentViewController method. This requires additional native code and some iOSApi units.  

We will continue investigation here, as an alternative you can use the above approach or use the workaround to programmatically create/destroy the UICollectionView.

Kind Regards, 
Pieter

Thanks, but I can see no mention of this in the documentation.

The same thing happens if I use Show rather than ShowModal. Is that not supported either?

The responsible developer will look into this upon return from winter holiday.

Thank you. So we are clear is that your way of saying that it won't be looked at until the New Year?

Yes

Hi, 


For native controls, its better to directly use them on the Main form, or present them as a separate view controller with the above code. Make sure that the CollectionView is instantiated a single time and is live during the application. Creating/Destroying it multiple times in a separate "Modal" form is not recommended. Toggling the visible property should also give you an identical experience but does not destroy the CollectionView.

Kind Regards, 
Pieter

Thanks, but in a large project this is a nightmare. I want to keep the code in seperate forms. I do not need to show them modally though.

You can add the collectionview on a separate form and then set the parent to the mainform if you need it, and toggle the visibility to show it. Using a modal form that creates/destroys the collection view is currently not supported. We will investigate here if we can add a non-visual component that handles multiple forms/frames.


Kind Regards, 
Pieter

Pieter,, thanks but as I said before this happens with Show as well as ShowModal so is not just a modal issue.

Yes, but it still creates and destroys the form. Currently, that's the issue for showing native controls.

Do you have any intention of trying to fix this?