I have a UICollectionViewController
defined as follows:
[<Register ("LandlordHome")>]
type LandlordHome (handle:IntPtr) =
inherit UICollectionViewController (handle)
override x.ViewDidLoad () =
base.ViewDidLoad ()
let collectionViewDelegate = new CollectionViewFlowDelegate(new IntPtr())
collectionViewDelegate.parent <- x
x.CollectionView.Delegate <- collectionViewDelegate
I omitted irrelevant code for clarity.
Next, I have a UICollectionViewDelegateFlowLayout
defined as follows:
[<Register ("CollectionViewFlowDelegate")>]
type CollectionViewFlowDelegate (handle:IntPtr) =
inherit UICollectionViewDelegateFlowLayout (handle)
let mutable parentViewController : UIViewController = null
member this.parent
with get() = parentViewController
and set(value) = parentViewController <- value
override x.ItemSelected(collectionView : UICollectionView, indexPath : NSIndexPath) =
let controller = new ChatControllerLandlord(new IntPtr())
controller.GetListingId <- ""
controller.GetPartnerId <- ""
controller.GetLandlordId <- ""
controller.GetPartnerName <- ""
parentViewController.PresentViewController(controller,true,null)
This is done in order to override the ItemSelected
method so that when I tap on the UICollectionViewCell
the code inside of it is executed.
However, when I tap on the cell nothing happens.
I tried your code , found the workaround.
Modify the construction method of CollectionViewFlowDelegate
as below:
let collectionViewDelegate = new CollectionViewFlowDelegate()
collectionViewDelegate.parent <- x
x.CollectionView.Delegate <- collectionViewDelegate
type CollectionViewFlowDelegate () =
inherit UICollectionViewDelegateFlowLayout ()