3

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

今天我遇到了一个有趣的问题。我试图覆盖可用 herewebView: shouldStartLoadWithRequest:上的方法。CDVViewContainer

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

@interface UITextField : UIControl <UITextInput> {

}

将转化为

[BaseType (typeof (UIControl))]
interface UITextField : UITextInput {
}

基于此,我翻译了

@interface CDVViewController : UIViewController <UIWebViewDelegate, CDVScreenOrientationDelegate>{

}

进入

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

}

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

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

我检查了 Apple Specifications,这实际上是一个 Protocol。谁能帮我弄清楚我做错了什么?

4

1 回答 1

5

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

于 2013-03-27T07:27:45.130 回答