gpt4 book ai didi

ios - 未调用 ItemSelected - Xamarin.iOS F#

转载 作者:行者123 更新时间:2023-11-29 00:04:26 25 4
gpt4 key购买 nike

我有一个 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 ()

关于ios - 未调用 ItemSelected - Xamarin.iOS F#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48522457/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com