I'm trying to implement the following interface in 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);
}
}
To do so I have the following code:
[<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
However this gives me the error:
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 ...'.
I don't understand this as there is no additional methods in the interface.
Note that your ICardViewDataSource
interface also implements INativeObject
. This means you need to implement all members of that interface too. In this case, there's a property called Handle
that is missing.
Also worth noting that it implements IDisposable
which means you may need to have a Dispose
method too.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.