Xamarin.ios 如何映射从MonoTouch中的两个类派生的接口?
我在外部库中有以下接口定义Xamarin.ios 如何映射从MonoTouch中的两个类派生的接口?,xamarin.ios,Xamarin.ios,我在外部库中有以下接口定义 @interface AGSGPS : UIView < CLLocationManagerDelegate > 问题在于UIView和CLLocationManagerDelegate都是类,这可以分解为以下代码: class AGSGPS : UIView, CLLocationManagerDelegate 这在C中是非法的# 想法?您不需要“映射”对象。尖括号中的类型是协议,这意味着您的AGSGPS对象采用该协议 检查文件 现在,采用协议意味着
@interface AGSGPS : UIView < CLLocationManagerDelegate >
问题在于UIView
和CLLocationManagerDelegate
都是类,这可以分解为以下代码:
class AGSGPS : UIView, CLLocationManagerDelegate
这在C中是非法的#
想法?您不需要“映射”对象。尖括号中的类型是协议,这意味着您的AGSGPS对象采用该协议
检查文件
现在,采用协议意味着您的对象应该实现所有协议的方法。要在ApiDefinition中实现这一点,只需将CLLocationManagerDelegate的方法视为属于AGSGPS类型,例如:
[BaseType (typeof (UIView))]
interface AGSGPS
{
[Export("locationManager:didUpdateHeading:")]
void UpdatedHeading(CLLocationManager lman, CLHeading heading);
// etc, include all CLLocationManagerDelegate's methods
}
我有一个可能的修复方法,我刚刚尝试并正在测试,我没有使用预定义的CLLocationManagerDelegate,而是在ApiDefinition文件中重新定义了它,然后能够从中派生,因为它是一个接口,而不是一个类,不是最优的,但总比什么都不做要好。我基本上做了同样的事情,在ApiDefinition中重新定义了接口并从中派生出来,仍然在开发全面的API,不过我们会看看它是如何工作的。
[BaseType (typeof (UIView))]
interface AGSGPS
{
[Export("locationManager:didUpdateHeading:")]
void UpdatedHeading(CLLocationManager lman, CLHeading heading);
// etc, include all CLLocationManagerDelegate's methods
}