【发布时间】:2017-12-25 14:49:11
【问题描述】:
这是我尝试在 UITable 为空时显示地图的代码
var mapView:GMSMapView?
func numberOfSections(in tableView: UITableView) -> Int {
if orders.count > 0 {
self.tableview.backgroundView = nil
self.tableview.separatorStyle = .singleLine
return 1
}
mapView = GMSMapView.map(withFrame: CGRect(x: 100, y: 100, width: 200, height: 200), camera: GMSCameraPosition.camera(withLatitude: 51.050657, longitude: 10.649514, zoom: 5.5))
//so the mapView is of width 200, height 200 and its center is same as center of the self.view
mapView?.center = self.view.center
self.tableview.backgroundView = mapView
return 0
}
但是项目崩溃了,原因是
libc++abi.dylib:以 NSException 类型的未捕获异常终止
【问题讨论】:
-
您能调试一下并告诉我哪条线路崩溃了吗?从 viewdidload 开始。
-
并且还在控制台日志中显示完整的错误报告。
-
我已经导入了 GoogleMaps 并在 AppDelegate 中使用了 Google Key 但我仍然有理由:
'Google Maps SDK for iOS must be initialized via [GMSServices provideAPIKey:...] prior to use'
标签: swift xcode google-maps uitableview swift4