C# 在绑定项目中实现MKAnnotation协议
Hi-ma正在尝试在iOS绑定项目中创建以下声明。 源目标C声明如下C# 在绑定项目中实现MKAnnotation协议,c#,objective-c,xamarin.ios,cocoa-bindings,ibeacon,C#,Objective C,Xamarin.ios,Cocoa Bindings,Ibeacon,Hi-ma正在尝试在iOS绑定项目中创建以下声明。 源目标C声明如下 @interface LeBlutrackerDevice : LeDevice <MKAnnotation> { CLLocationCoordinate2D _coord; } @property (nonatomic,readonly,copy) NSString *title; @property (nonatomic,readonly,copy) NSString *subtitle; @pro
@interface LeBlutrackerDevice : LeDevice <MKAnnotation>
{
CLLocationCoordinate2D _coord;
}
@property (nonatomic,readonly,copy) NSString *title;
@property (nonatomic,readonly,copy) NSString *subtitle;
@property (nonatomic,readonly) CLLocationCoordinate2D coordinate;
@property (nonatomic, strong) NSString *svInfo;
@property (nonatomic, strong) NSString *navInfo;
@property (nonatomic,readonly) enum LE_DEVICE_STATE state;
@property (nonatomic,strong) id <LeBlutrackerDeviceDelegate> delegate;
@property (readonly) BOOL bcKeyEnabled;
- (BOOL) writeBroadcastKey: (NSData *) key;
@end
我得到了以下错误
Target GenerateBindings:
ApiDefinition.cs(309,48): error CS0527: Type `MonoTouch.MapKit.MKAnnotation' in interface list is not an interface
ApiDefinition.cs(313,10): warning CS0108: `SticknFind.LeBlutrackerDevice.Title' hides inherited member `MonoTouch.MapKit.MKAnnotation.Title'. Use the new keyword if hiding was intended
ApiDefinition.cs(316,10): warning CS0108: `SticknFind.LeBlutrackerDevice.Subtitle' hides inherited member `MonoTouch.MapKit.MKAnnotation.Subtitle'. Use the new keyword if hiding was intended
ApiDefinition.cs(319,26): warning CS0108: `SticknFind.LeBlutrackerDevice.Coordinate' hides inherited member `MonoTouch.MapKit.MKAnnotation.Coordinate'. Use the new keyword if hiding was intended
有人试图为SticknFind SDK创建绑定吗?请让我知道,因为我非常高兴在GitHub上发布最终结果
如果我尝试从IMKAnnotation继承它,我会得到以下错误
btouch: No [Export] attribute on property SticknFind.LeBlutrackerDevice.Coordinate
Task "BTouch" execution -- FAILED
您希望从接口而不是类型继承,这是导致第一个CS0527错误的原因 它是用
[Protocol]
属性修饰的接口(因此它将匹配ObjC声明)。它还将解决后面的CS0108错误,因为该类型具有不属于协议的额外成员
因此,这应该解决这个问题:
[BaseType (typeof (LeDevice))]
public partial interface LeBlutrackerDevice : IMKAnnotation {
...
}
这还不够,在执行此操作时,会出现隐藏坐标特性的错误,或者,如果删除该特性,则不会导出特性坐标。无论哪种方式,我在使用界面时都会遇到一个ishte错误,坐标不会在IMKAnnotation上导出,请参见编辑的post@DiegoColombo:由于Xamarin.iOS()中的错误,此操作不起作用-atm解决此问题的唯一方法是将您希望从LeBlutrackerDevice中的MKAnnotation中内联的API。哦,希望此修复程序尽快发布,但无论如何,不确定IMKAnnotation上缺少的属性。它没有objective MKC注释协议的标题和副标题属性
[BaseType (typeof (LeDevice))]
public partial interface LeBlutrackerDevice : IMKAnnotation {
...
}