Xcode版本: 8.1
目标:
用自定义替换本地infoWindow
问题:
myView.delegate = self
,则显示信号SIGABRT(参见我的代码和我的研究#21)我做了什么:
将mapView函数插入ViewController.swift:
override func viewDidLoad() {
super.viewDidLoad()
...
let camera = GMSCameraPosition.camera(withLatitude: latitude,
longitude: Longitude, zoom: 16)
let mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera)
mapView.delegate = self // Thread 1:signal SIGABRT shown if i add this line
mapView.isMyLocationEnabled = true
self.view = mapView
let marker = GMSMarker()
marker.position = CLLocationCoordinate2DMake(latitude, Longitude)
marker.title = "Me"
marker.map = mapView
mapView.selectedMarker = marker
}
func mapView(_ mapView: GMSMapView, markerInfoWindow marker: GMSMarker) -> UIView? {
let infoWindow = Bundle.main.loadNibNamed("CustomInfoWindow", owner: self.view, options: nil)!.first! as! CustomInfoWindow
infoWindow.title.text = marker.title
return infoWindow
}
我的研究:
答案 0 :(得分:4)
您是否实施了GMSMapViewDelegate?
ViewController: GMSMapViewDelegate {
...
}
似乎是您收到错误(崩溃),因为您将委托设置为self,但您的控制器不符合该协议。