Forum Xamarin Xamarin.iOS

Cant override UICollectionViewCell Highlighted

I am having trouble overriding cell highlighted and unhighlighted events. i have a view controller which contains a UICollectionView and various buttons and labels. when i try to override highlighted the method can't be found. i then change the inheritance from UIViewController to UICollectionViewController which allows me to override the highlighted, but the app crashes when i load the controller.

So my question is how do i override the cell highlighted in the view controller class?
public partial class ClientEvaluationsViewController : UIViewController, IUICollectionViewDataSource


  • BerayBentesenBerayBentesen TRUniversity ✭✭✭✭

    You must override that method adapter. To access that event in UIViewController, pass EvenHandler as a parameter in your adapter and call it in cell highlighted method. Than you will be able to access inside ViewController.

  • @BerayBentesen have you got an example? because when i add a class to the collectionview i can no longer access the collectionview weakdata source within the UIViewController

  • @BerayBentesen
    this is the code in my class i am adding to the collection view

    ` public partial class ExistingCollectionView : UICollectionViewDelegate

        public ExistingCollectionView (IntPtr handle) : base (handle)
        public override void ItemHighlighted(UICollectionView collectionView, NSIndexPath indexPath)
            base.ItemHighlighted(collectionView, indexPath);
            var cell = (ExistingEvaluationCell)collectionView.DequeueReusableCell("ExistingEvaluations", indexPath);
            cell.Layer.Opacity = 0.5f;
        public override void ItemUnhighlighted(UICollectionView collectionView, NSIndexPath indexPath)
            base.ItemUnhighlighted(collectionView, indexPath);
            var cell = (ExistingEvaluationCell)collectionView.DequeueReusableCell("ExistingEvaluations", indexPath);
            cell.Layer.Opacity = 1.0f;

    but how do i access this in the my viewcontroller which is a level up?

Sign In or Register to comment.