Open denzerd opened 5 years ago
The ViewController
property on CollectionViewRenderer
is an ItemsViewController
, which subclasses UICollectionViewControler
. This might allow you to do what you want to do.
It seems actually getting hold of the real UICollectionView
being difficult is just a "feature" of iOS:
@GalaxiaGuy Thanks this is at least an easier way to get the ViewController itself as the two solutions we found In the Xamarin Board.
However the issue persists as the documentation clearly states that the CollectionView is of type UICollectionView under iOS, so either the documentation has to be adjusted or there is something wrong with CollectionViewRenderer under iOS.
Thanks again, good solution for the moment.
Yeah, this is an issue with how iOS structures the classes around UICollectionView. If we actually set Control to be the UICollectionView itself, things get weird with layout; we have to go through the intermediary wrapper control.
I'll see what we can do about noting this in the docs, and possibly adding a more direct property for accessing the UICollectionView itself.
@denzerd There is currently no UICollectionViewControllerWrapperView
in the source code as far as I can see. You could currently get the UICollectionView
from ItemsViewController.CollectionView
property in ItemsViewRenderer
. As for the documentation, CollectionViewRenderer
is implementing a UIView
now. I agree that it should be updated.
Is there any update on this?
Description
According to the documentations https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/custom-renderer/renderers#views Xamarin Forms' CollectionView should be of type UICollectionView under iOS. However when implementing a Customrenderer with the help of CollectionViewRenderer the Control is of type UICollectionViewControllerWrapperView. It is difficult or can just be done by tricks to get the actual UICollectionView to manipulate the rendering.
Steps to Reproduce
Expected Behavior
Control of an iOS CollectionViewRenderer is of type UICollectionView
Actual Behavior
Control of an iOSCollectionViewRenderer is of type UICollectionViewControllerWrapperView
Basic Information
Links
Had a question on the Xamarin community about it already with two workarounds: https://forums.xamarin.com/discussion/156810/ios-collectionviewrenderer-get-uicollectionview#latest