MKAnnotationView 问题自初始化器(将 swift 2.0 转换为 swift 2.3)

MKAnnotationView problems self initializiers (convert swift 2.0 to swift 2.3)

我现在正在将一个 iOS 应用程序从 Swift 2.0 转移到 2.3 并且 运行 进入非常简单的问题...

那是我的 AnnotationView class:

class PPLocationAnnotationView: MKAnnotationView {

    private let annotationSize = CGSize(width: 60.0, height: 60.0)

    init() {
        let annotationFrame = CGRect(
            origin: CGPointZero,
            size: annotationSize)
        super.init(frame: annotationFrame)

        opaque = true
        image = UIImage.annotationLocationIcon()
        enabled = true
        canShowCallout = false
        centerOffset = CGPoint(x: 0.0, y: -(UIImage.annotationLocationIcon().size.height / 2) + 10.0)

        layer.shouldRasterize = true
        layer.rasterizationScale = UIScreen.mainScreen().scale
    }
}

发生的错误是: "Must call a designated initializer of the superclass MKAnnotationView"

所以我把这个改成了:

convenience init(frame: CGRect) {
        let annotationFrame = CGRect(
            origin: CGPointZero,
            size: annotationSize)
        self.init(frame: annotationFrame)

现在我收到一个新错误:"use of 'self' in method call 'setupAudioSession' before super.init initializes self"

我不明白...

如果有人能提供帮助就太好了。

干杯

MKAnnotationView 的指定初始化器是init(annotation: MKAnnotation?, reuseIdentifier: String?)

您需要在初始化程序中调用它。