从iOS 7到8,我的代码运行良好.昨天更新了我的引脚上的自定义图像被标准引脚图像替换.有什么建议?
我的代码:
extension ViewController: MKMapViewDelegate {
func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView! {
if annotation is MKUserLocation {
return nil
}
let reuseId = String(stringInterpolationSegment: annotation.coordinate.longitude)
var pinView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId) as? MKPinAnnotationView
if pinView == nil {
pinView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: reuseId)
pinView!.canShowCallout = true
pinView!.image = getRightImage(annotation.title!!)
}
let button = UIButton(type: UIButtonType.DetailDisclosure)
pinView?.rightCalloutAccessoryView = button
return pinView
}
}
Run Code Online (Sandbox Code Playgroud)
获取图像的函数UIImage根据名称返回:
func getRightImage (shopName:String)-> UIImage{
var correctImage = UIImage()
switch shopName
{
case …Run Code Online (Sandbox Code Playgroud)