(MapView)更改了Userlocation图像有助于恢复

时间:2017-05-27 00:06:17

标签: ios swift mkmapview mkannotation

我正在使用MapKit并且我更改了Annotation的图像,但问题是,Userlocation(蓝点)也改变了它的图片(我不想那样)。如何将其恢复正常。另外,我在标注中添加了一个小按钮(正如您可能已经猜到的那样)被添加到我的位置,它不应该在那里。我的代码如下......

    func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
        if !(annotation is MKUserLocation) {
            print("annotation is MKUserLocation")
        }
        var annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: "identifier")
            if annotationView == nil{
                annotationView = MKAnnotationView(annotation: annotation, reuseIdentifier: "identifier")
                annotationView!.canShowCallout = true
                annotationView!.rightCalloutAccessoryView = UIButton(type: .detailDisclosure)

                let pinImg = UIImage(named: "curz")
                let size = CGSize(width: 50, height: 50)
                UIGraphicsBeginImageContext(size)
                pinImg!.draw(in: CGRect(x: 0, y: 0, width: size.width, height: size.height))
                let resizedImage = UIGraphicsGetImageFromCurrentImageContext()
                UIGraphicsEndImageContext()
                annotationView!.image = resizedImage
                }
        else {
        annotationView!.annotation = annotation
      }
    return annotationView
   }

        //Var SelectedAnnotation
        var anotacionSeleccionada : MKPointAnnotation!

    func mapView(_ mapView: MKMapView, annotationView view: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) {
        if control == view.rightCalloutAccessoryView {
        anotacionSeleccionada = view.annotation as? MKPointAnnotation
        performSegue(withIdentifier: "vista", sender: self)
        }
      }


    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        if let destination = segue.destination as? ViewController {
        destination.pin = anotacionSeleccionada
       }
     }

1 个答案:

答案 0 :(得分:1)

set rSession = CreateObject("Redemption.RDOSession") rSession.MAPIOBJECT = Application.Session.MAPIOBJECT Item.Save set rItem = rSession.GetRDOObjectFromOutlookObject(Item) set attach = rItem.Attachments(1) 'PR_ATTACH_LONG_FILENAME_W attach.Fields("http://schemas.microsoft.com/mapi/proptag/0x3707001F") = "whatever.pdf" 'PR_ATTACH_FILENAME_W attach.Fields("http://schemas.microsoft.com/mapi/proptag/0x3704001F") = "whatever.pdf" 'PR_DISPLAY_NAME_W attach.Fields("http://schemas.microsoft.com/mapi/proptag/0x3001001F") = "whatever.pdf" rItem.Save 函数中,在开头添加此行:

viewFor annotation

因为如果是if annotation is MKUserLocation { return nil } ,你不想做任何事情。