Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

UICollectionViewSource.ItemSelected() Not Firing

$
0
0

I've encountered some weird behavior and am wondering if this is a bug or the intended behavior.

I've got a UICollectionView inside of a UIViewController that displays some content in a horizontal fashion via a custom UICollectionViewSource. I've overriden the ItemSelected() method in the UICollectinViewSource so that when the user taps a cell item, it will launch another view controller to display the details of that item.

However, it appears that the ItemSelected() method was not firing at all. After some troubleshooting, I've figured out that if I wire the UICollectionViewController.DecelerationEnded event, UICollectionViewSource.ItemSelected() does not fire. But if I do not wire UICollectionViewController.DecelerationEnded, then UICollectinViewSource.ItemSelected() will fire as intended.

Is this the intended behavior or a potential defect? Code below has been shorten for brevity. But hopefully explains the issue I'm running into.

public class MyCustomCollectionViewSource : UICollectionViewSource
{
   //blah blah blah

   public override void ItemSelected(UICollectionView collectionView, NSIndexPath indexPath)
   {
      //Code to handle a selected cell
      //This does not fire if the hosting UICollectionView contains a wired event for DecelerationEnded
   }
}

var myCollectionView = new UICollectionView();
myCollectionView.Source = new MyCustomCollectionViewSource();

//If I wire this up, the ItemSelected method never fires.
myCollectionView.DecelerationEnded += MyDecelerationEndedHandler;

Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>