Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios mapKit不显示注释_Ios_Swift_Swift3_Mapkit_Mkannotationview - Fatal编程技术网

Ios mapKit不显示注释

Ios mapKit不显示注释,ios,swift,swift3,mapkit,mkannotationview,Ios,Swift,Swift3,Mapkit,Mkannotationview,我的代码并没有显示每个PIN的标题或副标题。引脚显示在这些坐标上。但是,单击管脚时,不会显示任何内容。我只想引脚是不同的颜色,当点击他们显示一条消息 import UIKit import MapKit class MyPointAnnotation : MKPointAnnotation { var pinTintColor: UIColor? } class ViewController: UIViewController, MKMapViewDelegate { @IBOutlet v

我的代码并没有显示每个PIN的标题或副标题。引脚显示在这些坐标上。但是,单击管脚时,不会显示任何内容。我只想引脚是不同的颜色,当点击他们显示一条消息

import UIKit
import MapKit

class MyPointAnnotation : MKPointAnnotation {
var pinTintColor: UIColor?
}

class ViewController: UIViewController, MKMapViewDelegate {
@IBOutlet var jmap: MKMapView!

override func viewDidLoad() {
    super.viewDidLoad()

    jmap.delegate = self

    let hello = MyPointAnnotation()
    hello.coordinate = CLLocationCoordinate2D(latitude: 40, longitude: -73)
    hello.title = "My Shop"
    hello.subtitle = "its cool"
    hello.pinTintColor = .red


    let hellox = MyPointAnnotation()

    hellox.coordinate = CLLocationCoordinate2D(latitude: 34, longitude: -72)

    hellox.title = "NOW"

    hellox.title = "JUdo"
    hellox.pinTintColor = .blue

    jmap.addAnnotation(hello)
    jmap.addAnnotation(hellox)
}

func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
    var annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: "myAnnotation") as? MKPinAnnotationView

    if annotationView == nil {
        annotationView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: "myAnnotation")
    } else {
        annotationView?.annotation = annotation
    }

    if let annotation = annotation as? MyPointAnnotation {
        annotationView?.pinTintColor = annotation.pinTintColor



    }
    return annotationView
    }}

添加
annotationView?.canShowCallout=true
之前,返回
annotationView

在什么函数中,我应该把它放进去。@sillymilly-很明显,Grifas是在谈论你的
地图视图(uuu:viewFor:)
。(这是返回
annotationView
的唯一函数)