【问题标题】:How to bind the Delegate used in the Objective c class in Xamarin?如何绑定 Xamarin 中 Objective c 类中使用的 Delegate?
【发布时间】:2014-08-18 20:31:45
【问题描述】:

您好,我刚开始将 Objective-C 绑定到 c#。我使用 Objective Sharpie 进行 C# 绑定。我生成了 ApiDefinitions.cs 文件,但生成的文件出现了更多错误。

错误: 错误 CS0527:接口列表中的类型“MonoTouch.UIKit.UITableViewDelegate”不是接口 (CS0527) (IOSBinding) 此行导致错误

C#代码

 [BaseType (typeof (UITableView))]  
 public partial interfaceA interfacename : UITableViewDataSource, UITableViewDelegate{

    }

目标 C

 @interface interfaceA:UITableView<UITableViewDataSource, UITableViewDelegate>{

}

如何在c#中绑定UITableViewDataSource、UITableViewDelegate?

【问题讨论】:

  • 应该是“public partial class interfaceA: UITableViewDataSource, UITableViewDelegate”
  • 在 ApiDefinitions.cs 中会包含类声明吗?
  • 能否在ApiDefinitions.cs文件中提供绑定Interface的代码

标签: c# ios xamarin.ios xamarin


【解决方案1】:

您不需要实际列出它实现的协议,绑定将在没有它们的情况下工作。

旁注:由于协议的工作方式,您将无法有效地声明一个类使用 Classic API 实现了协议。也就是说,即将推出的统一 API 解决了这个问题,并允许您这样做。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-05-17
    • 1970-01-01
    • 2019-05-18
    • 1970-01-01
    • 1970-01-01
    • 2016-02-03
    • 2021-04-27
    • 1970-01-01
    相关资源
    最近更新 更多