我创建了这两个变量 var googleMap = GMSMapView()@IBOutlet weak var mapView: UIView! 我在viewDidLoad()中将googleMap指定给mapView override func viewDidLoad() { super.viewDidLoad() self.mapView = self.googleMap //Throwing error
var googleMap = GMSMapView() @IBOutlet weak var mapView: UIView!
我在viewDidLoad()中将googleMap指定给mapView
override func viewDidLoad() { super.viewDidLoad() self.mapView = self.googleMap //Throwing error as 'Google Maps SDK for iOS must be initialized via [GMSServices provideAPIKey:...] prior to use' }
我在AppDelegate.swift中提供密钥
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Override point for customization after application launch. GMSServices.provideAPIKey("AIzaSyB6aQxEmza-wUpOPU60aREWReRIAEAvrHs") return true }
任何人都可以指出我解决这个问题的方向吗?
您不会以这种方式将GMSMapView分配给您的UIView.这是你如何做到的将UIView的类更改为GMSMapView