Per*_*lue 7 xcode dictionary ios swift
我正在尝试添加地图,GMSMapView但是当我为视图创建插座时,我遇到了错误.
以下是代码段:
import UIKit
import GoogleMaps
class MapViewController: UIViewController {
@IBOutlet weak var mapVIew: GMSMapView!
@IBOutlet weak var mapCenterPinImage: UIImageView!
@IBOutlet weak var pinImageVerticalConstraint: NSLayoutConstraint!
var searchedTypes = ["bakery", "bar", "cafe", "grocery_or_supermarket", "restaurant"]
let locationManager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
locationManager.delegate = self
locationManager.requestWhenInUseAuthorization()
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "Types Segue" {
let navigationController = segue.destinationViewController as! UINavigationController
let controller = navigationController.topViewController as! TypesTableViewController
controller.selectedTypes = searchedTypes
controller.delegate = self
}
}
}
Run Code Online (Sandbox Code Playgroud)
我遇到了以下错误
@IBOutlet weak var mapVIew: GMSMapView!:
Run Code Online (Sandbox Code Playgroud)
请有人帮助我
明确的答案不是这个问题的正确答案.如果其他人遇到此问题,问题是所需的框架未导入.在这种情况下,GoogleMaps.对此的修复是在文件添加的顶部
import GoogleMaps
Run Code Online (Sandbox Code Playgroud)
另一个例子是如果在添加MkMapView后出现错误.
@IBOutlet weak var mapView: MKMapView
Run Code Online (Sandbox Code Playgroud)
为此,您必须导入MapKit
import MapKit
Run Code Online (Sandbox Code Playgroud)
注意:更新此答案以避免误解,因为我之前回答错误。感谢@Inn0vative1指出错误
为此你必须导入 MapKit
import MapKit
Run Code Online (Sandbox Code Playgroud)
您的viewController未确认协议,请遵守CLLocationManagerDelegate协议
class MapViewController: UIViewController,CLLocationManagerDelegate {
}
Run Code Online (Sandbox Code Playgroud)