[英]F# Interface Implementation Error
我正在尝试在F#中实现以下接口:
using Foundation;
using ObjCRuntime;
using System;
using System.Runtime.CompilerServices;
using UIKit;
namespace Softweb.Xamarin.Controls.iOS
{
[Protocol (Name = "ZLSwipeableViewDataSource", WrapperType = typeof(CardViewDataSourceWrapper))]
public interface ICardViewDataSource : INativeObject, IDisposable
{
//
// Methods
//
[Export ("nextViewForSwipeableView:"), Preserve (Conditional = true), CompilerGenerated]
UIView NextCardForCardView (CardView cardView);
}
}
为此,我有以下代码:
[<Register ("BackgroundAnimationViewControllerDataSource")>]
type BackgroundAnimationViewControllerDataSource () =
interface ICardViewDataSource with
member this.NextCardForCardView(cardView : CardView) =
let card = new UIView()
card.Frame <- CGRect()
card.BackgroundColor <- UIColor.Blue
card.Layer.ShouldRasterize <- true
card
但这给了我错误:
No implementation was given for 'ObjCRuntime.INativeObject.get_Handle() : nativeint'. Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, eg 'interface ... with member ...'.
我不明白这一点,因为界面中没有其他方法。
请注意,您的ICardViewDataSource
接口还实现了INativeObject
。 这意味着您也需要实现该接口的所有成员。 在这种情况下,缺少名为Handle
的属性。
同样值得注意的是,它实现了IDisposable
,这意味着您可能还需要使用Dispose
方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.