嗨,马试图在ios绑定项目中创建以下声明。
源目标c声明如下
@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
这就是我在apiDefinition.cs中看到的
[Model, BaseType (typeof (LeDevice))]
public partial interface LeBlutrackerDevice : MKAnnotation
{
[Export ("title", ArgumentSemantic.Copy)]
string Title { get; }
[Export ("subtitle", ArgumentSemantic.Copy)]
string Subtitle { get; }
[Export ("coordinate")]
CLLocationCoordinate2D Coordinate { get; }
[Export ("svInfo", ArgumentSemantic.Retain)]
string SvInfo { get; set; }
[Export ("navInfo", ArgumentSemantic.Retain)]
string NavInfo { get; set; }
[Export ("state")]
LE_DEVICE_STATE State { get; }
[Export ("delegate", ArgumentSemantic.Retain)]
LeBlutrackerDeviceDelegate Delegate { get; set; }
[Export ("bcKeyEnabled")]
bool BcKeyEnabled { get; }
[Export ("writeBroadcastKey:")]
bool WriteBroadcastKey (NSData key);
}
我得到以下错误
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 {
...
}
关于c# - 在绑定(bind)项目中实现MKAnnotation协议(protocol),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/21505518/