C#-UICollectionViewCell定义F#
作者:互联网
我如何将以下C#代码转换为F#:
public class AnimalCell : UICollectionViewCell
{
[Export ("initWithFrame:")]
public AnimalCell (RectangleF frame) : base (frame) {}
}
我尝试按照以下链接中的示例进行操作,但是,我不知道下一步如何进行:
Overriding Constructors in F#
到目前为止,我想出的是:
[<Register ("AnimalCell")>]
type AnimalCell (handle: IntPtr) as this =
inherit UICollectionViewCell (handle)
我将在哪里添加导出以及参数?我知道我应该使用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
标签:f,xamarin,uicollectionview,ios,c 来源: https://codeday.me/bug/20191110/2013965.html