【问题标题】:can't show map annotation in Swift无法在 Swift 中显示地图注释
【发布时间】:2018-02-07 02:48:44
【问题描述】:

我正在尝试添加地图注释,但是当我尝试运行该应用程序时,地图注释不显示,并给出错误消息。

添加地图注释[3668:68848] 无法插入来自的法律归属 角落 4

实际上,我只是在https://www.youtube.com/watch?v=hRextIKJCnI 中按照 Youtube 上的教程进行操作,在 swift3 中,此代码似乎有效,但我不知道为什么它对我不起作用。我正在使用 swift 4 和 Xcode 9.2

我已经尝试过堆栈溢出的解决方案,但它在我身上不起作用,在这里Could not inset legal attribution from corner 4 swift

这里出了什么问题?

import UIKit
import MapKit

class ViewController: UIViewController {


    @IBOutlet weak var mapKitView: MKMapView!



    override func viewDidLoad() {
        super.viewDidLoad()

        let span : MKCoordinateSpan = MKCoordinateSpanMake(0.001, 0.001)
        let location : CLLocationCoordinate2D = CLLocationCoordinate2DMake(-6.239116, 106.789415)
        let region : MKCoordinateRegion = MKCoordinateRegionMake(location, span)
        mapKitView.setRegion(region, animated: true)

        let annotation =  MKPointAnnotation()
        annotation.title = "My Shop"
        annotation.subtitle = "Come visit here"
        mapKitView.addAnnotation(annotation)

    }




}

【问题讨论】:

    标签: ios swift mapkit mapkitannotation


    【解决方案1】:

    你是说:

        let annotation =  MKPointAnnotation()
        annotation.title = "My Shop"
        annotation.subtitle = "Come visit here"
        mapKitView.addAnnotation(annotation)
    

    这就是您要说的全部。但是……那个注解没有coordinate!那么你如何想象地图可能知道它应该去哪里?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多