您好,您好,您正在尝试在 iOS 绑定(bind)项目中创建以下声明。 源 Objective 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 创建绑定(bind)吗?请让我知道,因为我非常乐意在 GitHub 上发布最终结果。
如果我尝试从 IMKAnnotation 继承它,我会收到以下错误
btouch: No [Export] attribute on property SticknFind.LeBlutrackerDevice.Coordinate
Task "BTouch" execution -- FAILED
最佳答案
您想从接口(interface)而不是类型继承,这就是导致第一个 CS0527 错误的原因。
它是用 [Protocol]
属性修饰的接口(interface)(因此它将匹配 ObjC 声明)。它还将解决后来的 CS0108 错误,因为该类型具有不属于协议(protocol)一部分的额外成员。
所以这应该可以解决:
[BaseType (typeof (LeDevice))]
public partial interface LeBlutrackerDevice : IMKAnnotation {
...
}
关于c# - 在 Binding 项目中实现 MKAnnotation 协议(protocol),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21505518/