我不确定如何用快速的语言注释 map 。我不知道如何创建NSObject类。以下是我尝试但无法运行的代码:
import Foundation
import MapKit
class MapPin : MKAnnotation
{
var mycoordinate: CLLocationCoordinate2D
var mytitle: String
var mysubtitle: String
func initMapPin (coordinate: CLLocationCoordinate2D!, title: String!, subtitle: String!)
{
mycoordinate = coordinate
mytitle = title
mysubtitle = subtitle
}
}
最佳答案
这会给您结果:
class MapPin : NSObject, MKAnnotation {
var coordinate: CLLocationCoordinate2D
var title: String?
var subtitle: String?
init(coordinate: CLLocationCoordinate2D, title: String, subtitle: String) {
self.coordinate = coordinate
self.title = title
self.subtitle = subtitle
}
}
关于ios - MKA注解Swift,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24233873/