xamarin.ios - 如何绑定(bind)到 Xamarin.iOS 中的基本类型和协议(protocol)

标签 xamarin.ios xamarin

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

不过今天我遇到了一个有趣的问题。我试图覆盖 CDVViewContainer 上的 webView: shouldStartLoadWithRequest: 方法 available here .

我看过 Xamarin Binding Guide和 Xamarin Advanced Binding guide .这两个都注意到协议(protocol)类似于接口(interface),如高级绑定(bind)指南中所示

@interface UITextField : UIControl <UITextInput> {

}

会转化为

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

基于此,我翻译了

@interface CDVViewController : UIViewController <UIWebViewDelegate, CDVScreenOrientationDelegate>{

}

进入

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

}

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

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

我检查了 Apple 规范,并且 this is in fact a Protocol .谁能帮我弄清楚我做错了什么?

最佳答案

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

关于xamarin.ios - 如何绑定(bind)到 Xamarin.iOS 中的基本类型和协议(protocol),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15648733/

相关文章:

mono - 如何在Mac上的Xamarin Studio中添加本地Nuget包源?

iOS - 保存数据以便在应用程序外部轻松访问

mvvm - 使用参数绑定(bind)命令

ios - Xamarin iOS:找不到适用于iPad mini的模拟器,没有最新的iOS版本11.4.1

c# - 向后导航不会释放内存

ios - Xamarin iOS中使用NSSuperscriptAttributeName的NSAttributedString

c# - 如何在 .NET Core 中使用 xUnit 测试 Xamarin ViewModel?

.net - 单点登录服务器/页面

ios - Xamarin 模板 View

xamarin - 使用 Shell 时如何在 Xamarin.Forms 中设置导航文本颜色