簡體   English   中英

UICollectionViewCell定義F#

[英]UICollectionViewCell Definition F#

我如何將以下C#代碼翻譯成F#:

public class AnimalCell : UICollectionViewCell
{
[Export ("initWithFrame:")]
  public AnimalCell (RectangleF frame) : base (frame) {}
}

我嘗試按照下面的鏈接中的示例,但是,我不知道如何繼續下一步: 在F#中覆蓋構造函數

到目前為止我想出的是:

[<Register ("AnimalCell")>]
type AnimalCell (handle: IntPtr) as this = 
    inherit UICollectionViewCell (handle)

我在哪里添加Export以及參數? 我知道我應該使用new()但我不知道如何繼續。

這樣的事情會讓你開始:

F# UICollectionViewCell子類

[<Register ("AnimalCell")>]
type AnimalCell =   
    inherit UICollectionViewCell

    [<DefaultValue>] static val mutable private id : NSString
    static member init = 
        printfn "Initializing AnimalCell."
        AnimalCell.id <- new NSString("animalCell")

    [<Export("init")>]
    new() = { inherit UICollectionViewCell() } then AnimalCell.init
    [<Export("initWithFrame:")>]
    new(frame: CGRect) = { inherit UICollectionViewCell(frame) } then AnimalCell.init
    [<Export("initWithCoder:")>]
    new(coder: NSCoder) = { inherit UICollectionViewCell(coder) } then AnimalCell.init

    new(handle: IntPtr) = { inherit UICollectionViewCell(handle) } then AnimalCell.init

    override this.ReuseIdentifier = AnimalCell.id

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM