未调用 ItemSelected - Xamarin.iOS F#
ItemSelected not called - Xamarin.iOS F#
我有一个UICollectionViewController
定义如下:
[<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
为了清楚起见,我省略了不相关的代码。
接下来,我有一个UICollectionViewDelegateFlowLayout
定义如下:
[<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)
这样做是为了覆盖 ItemSelected
方法,这样当我点击 UICollectionViewCell
时,其中的代码就会被执行。
但是,当我点击单元格时没有任何反应。
我试过你的代码,找到了解决方法。
修改CollectionViewFlowDelegate
的构造方法如下:
let collectionViewDelegate = new CollectionViewFlowDelegate()
collectionViewDelegate.parent <- x
x.CollectionView.Delegate <- collectionViewDelegate
type CollectionViewFlowDelegate () =
inherit UICollectionViewDelegateFlowLayout ()
我有一个UICollectionViewController
定义如下:
[<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
为了清楚起见,我省略了不相关的代码。
接下来,我有一个UICollectionViewDelegateFlowLayout
定义如下:
[<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)
这样做是为了覆盖 ItemSelected
方法,这样当我点击 UICollectionViewCell
时,其中的代码就会被执行。
但是,当我点击单元格时没有任何反应。
我试过你的代码,找到了解决方法。
修改CollectionViewFlowDelegate
的构造方法如下:
let collectionViewDelegate = new CollectionViewFlowDelegate()
collectionViewDelegate.parent <- x
x.CollectionView.Delegate <- collectionViewDelegate
type CollectionViewFlowDelegate () =
inherit UICollectionViewDelegateFlowLayout ()