[英]SWIFT: try to use delegate method of objective c class
I have an existing Objective-C SDK (AugmentedKit SDK)
. 我有一个现有的Objective-C SDK (AugmentedKit SDK)
。 I am trying to use it with Swift
. 我试图用它与Swift
。 AugmentedKit SDK
has a class called ' AKSurfaceView
' that implements a delegate to ' AKViewDataSource
' protocol. AugmentedKit SDK
有一个名为' AKSurfaceView
'的类,它实现了对' AKViewDataSource
'协议的委托。
@class AKSurfaceView;
@protocol AKViewDataSource;
@protocol AKViewDelegate<AKViewDataSource>
AKViewDataSource looks like this: AKViewDataSource看起来像这样:
@protocol AKViewDataSource<NSObject>
@required
-(AKMarkerTemplate*) viewforMarker:(AKMarker*) marker;
I've created a briging file, implemented other methods from AKSurfaceView
, etc. - everything works fine but when I try to add a reference of the AKViewDelegate
to my UIViewControllerClass
it ends in a compile error: 我已经创建了一个briging文件,从AKSurfaceView
实现了其他方法等等 - 一切正常但是当我尝试将AKViewDelegate
的引用添加到我的UIViewControllerClass
它以编译错误结束:
"Type POIViewController
does not conform to protocol ' AKViewDataSource
'" “类型POIViewController
不符合协议' AKViewDataSource
'”
My implementation looks like this: 我的实现看起来像这样:
class POIViewController: UIViewController, AKViewDelegate {
My implementation of ' viewforMarker
' in SWIFT looks like this: 我在SWIFT中实现' viewforMarker
'看起来像这样:
func viewforMarker(marker:AKMarker) -> AKMarkerTemplate{
var markerView:SimpleMarker = SimpleMarker(frame: CGRectMake(0, 0, 230, 80))
markerView.title.text = marker.markerName
return markerView
}
Could please anybody help my to figure out how I have to implement ' viewforMarker
' so the delegate recognise it? 可以请任何人帮助我弄清楚我必须如何实现' viewforMarker
'以便委托人认出它?
它看起来像你的AKViewDelegate
是的子类AKViewDataSource
,在这种情况下,你将不得不顺应AKViewDelegate
和AKViewDataSource
,这意味着你将必须实现两个协议的必要方法。
确保已在Bridging-Header.h
导入了Obective-C类,并在swift类中添加了以下内容:
markerView.delegate = self
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.