我正在完成我的应用程序发布并发现了一个错误。我有几个UITableViewControllers
的单元格包含MKMapView
控件。
有时,当显示视图时,我的应用程序崩溃了。该日志显示以下消息:
[LogMessageLogging] 6.1无法检索CarrierName。 CTError:domain-2,code-5,errStr:((os / kern)失败) - [MTLDebugRenderCommandEncoder setDepthStencilState:]:2077:断言失败`depthStencilState与不同的设备关联'
CarrierName不会使应用程序崩溃(为什么会显示此日志消息仍然令人困惑),但第二个崩溃我的应用程序。
如何修复此错误?我可以压制断言吗?
以下是所有表格视图代码:
// Mark: TableView
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
return self.activities.count
}
override func numberOfSections(in tableView: UITableView) -> Int
{
return 1
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
let cell = tableView.dequeueReusableCell(withIdentifier: "cellFeed") as! ActivityCell
if indexPath.row >= self.activities.count
{
return cell
}
let activity = self.activities[indexPath.row]
cell.activity = activity
cell.name.text = activity.name
if activity.distance != nil
{
cell.distance.text = String(format: "%.2f km", activity.distance!.floatValue / 1000)
}
if activity.elevationGain != nil
{
cell.elevation.text = String(format: "%d m", Int(activity.elevationGain!))
}
if activity.date != nil
{
cell.date.text = DateHelper.getDateString(date: activity.date!)
}
// Map
if activity.map != nil && activity.map!.summary != nil
{
var coordinates = PolylineDecoder.decode(activity.map!.summary!)
DispatchQueue.main.async
{
// Clear old overlays
cell.map.removeOverlays(cell.map.overlays)
cell.map.delegate = self
let polyline = MKPolyline(coordinates: &coordinates, count: coordinates.count)
cell.map.add(polyline)
cell.map.setRegion(MKCoordinateRegionForMapRect(polyline.boundingMapRect), animated: false)
}
}
return cell
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
{
let index = indexPath.row
if index < self.activities.count
{
let activity = self.activities[index]
Utilities.post(Notifications.ActivityClicked, activity)
if self.navigationController != nil
{
self.navigationController!.popToRootViewController(animated: true)
}
}
}
// MARK: Map
func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer
{
let polylineRenderer = MKPolylineRenderer(overlay: overlay)
polylineRenderer.strokeColor = UIColor.red
polylineRenderer.lineWidth = 1
return polylineRenderer
}