I'm right now transferring an iOS app from Swift 2.0 to 2.3 and run into Problems on very simple thing...
that's my 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
}
}
The Error which occures is: "Must call a designated initializer of the superclass MKAnnotationView"
So i changed this bit to:
convenience init(frame: CGRect) {
let annotationFrame = CGRect(
origin: CGPointZero,
size: annotationSize)
self.init(frame: annotationFrame)
Now i get a new Error: "use of 'self' in method call 'setupAudioSession' before super.init initializes self"
i don't get it...
would be great if some could help with that.
cheers
The designated initializer of a MKAnnotationView is init(annotation: MKAnnotation?, reuseIdentifier: String?)
You need to call that in your initializer.