Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
未调用ItemSelected-Xamarin.iOS F#_Ios_F#_Xamarin.ios_Uicollectionview_Uicollectionviewdelegateflowlayout - Fatal编程技术网

未调用ItemSelected-Xamarin.iOS F#

未调用ItemSelected-Xamarin.iOS F#,ios,f#,xamarin.ios,uicollectionview,uicollectionviewdelegateflowlayout,Ios,F#,Xamarin.ios,Uicollectionview,Uicollectionviewdelegateflowlayout,我有一个UICollectionViewController定义如下: [<Register ("LandlordHome")>] type LandlordHome (handle:IntPtr) = inherit UICollectionViewController (handle) override x.ViewDidLoad () = base.ViewDidLoad () let collectionView

我有一个
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
    [<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 ()
让collectionViewDelegate=新的CollectionViewFlowDelegate()
collectionViewDelegate.parent