如何绑定到Xamarin.iOS中的基类型和协议

Jam*_*rke 3 xamarin.ios xamarin

我正在尝试构建一个使用Cordova库的xamarin应用程序.我一直在为我需要的库的组件进行自己的绑定,到目前为止,它一直运行良好.

今天我遇到了一个有趣的问题.我试图webView: shouldStartLoadWithRequest:CDVViewContainer 这里覆盖可用的方法.

我查看了Xamarin绑定指南和Xamarin 高级绑定指南.这两个都注意到协议类似于接口,并且如高级绑定指南中所示

@interface UITextField : UIControl <UITextInput> {

}
Run Code Online (Sandbox Code Playgroud)

会翻译成

[BaseType (typeof (UIControl))]
interface UITextField : UITextInput {
}
Run Code Online (Sandbox Code Playgroud)

基于此,我翻译了

@interface CDVViewController : UIViewController <UIWebViewDelegate, CDVScreenOrientationDelegate>{

}
Run Code Online (Sandbox Code Playgroud)

[BaseType (typeof (UIViewController))]
interface CDVViewController : UIWebViewDelegate {

}
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试制作我的绑定库时,我得到了

Cordova.cs(26,39): error CS0527L Type `MonoTouch.UIKit.UIWebViewDelegate' in interface list is not an interface. 
Run Code Online (Sandbox Code Playgroud)

我检查了Apple规范,这实际上是一个协议.任何人都可以帮我弄清楚我做错了什么?

mig*_*aza 5

这是对工具的限制.当您为其包含自己的定义时,您只能使用该语法来采用协议.采用已在外部定义中定义的协议时,它不起作用.