Alk*_*Alk 1 inheritance f# superclass uicollectionview swift
我在Swift中有以下类定义:
class LandlordHome : UIViewController, UICollectionViewDelegate, UICollectionViewDataSource {
}
Run Code Online (Sandbox Code Playgroud)
我试图在F#中创建它,但是F#中的继承模式只允许我继承这样一个类:
[<Register ("LandlordHome")>]
type LandlordHome (handle:IntPtr) =
inherit UIViewController (handle)
Run Code Online (Sandbox Code Playgroud)
如果我尝试添加这样的其他类:
[<Register ("LandlordHome")>]
type LandlordHome (handle:IntPtr) =
inherit UIViewController, UICollectionViewDelegate, UICollectionViewDataSource (handle)
Run Code Online (Sandbox Code Playgroud)
这会引发错误.
UICollectionViewDelegate而UICollectionViewDataSource不是class上课,而是protocols,这是像interfaceS INF#
所以你的看起来应该是这样的(抽象代码):
[<Register ("LandlordHome")>]
type LandlordHome (handle:IntPtr) =
inherit UIViewController (handle)
interface UICollectionViewDelegate with
// implementation of UICollectionViewDelegate
interface UICollectionViewDataSource with
// implementation of UICollectionViewDataSource
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
125 次 |
| 最近记录: |