Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 使用MKMapView-CarrierName和depthStencilState时的断言_Ios_Swift_Uitableview_Uiviewcontroller_Metal - Fatal编程技术网

Ios 使用MKMapView-CarrierName和depthStencilState时的断言

Ios 使用MKMapView-CarrierName和depthStencilState时的断言,ios,swift,uitableview,uiviewcontroller,metal,Ios,Swift,Uitableview,Uiviewcontroller,Metal,我正在完成我的应用程序发布,发现了一个bug。我有两个UITableViewControllers,其中的单元格包含MKMapView控件 有时,当视图显示时,我的应用程序崩溃。日志显示以下消息: [LogMessageLogging]6.1无法检索CarrierName。字符错误:域2,代码5,错误str:((操作系统/内核)失败) -[MTLDebugRenderCommandEncoder setDepthStencilState:]:2077:失败的断言“depthStencilStat

我正在完成我的应用程序发布,发现了一个bug。我有两个
UITableViewControllers
,其中的单元格包含
MKMapView
控件

有时,当视图显示时,我的应用程序崩溃。日志显示以下消息:

[LogMessageLogging]6.1无法检索CarrierName。字符错误:域2,代码5,错误str:((操作系统/内核)失败) -[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
}
//标记:TableView
重写func tableView(tableView:UITableView,numberofrowsinssection:Int)->Int
{
返回self.activities.count
}
重写func numberOfSections(在tableView:UITableView中)->Int
{
返回1
}
重写func tableView(tableView:UITableView,cellForRowAt indexath:indexPath)->UITableViewCell
{
让cell=tableView.dequeueReusableCell(标识符为:“cellFeed”)作为!ActivityCell
如果indexath.row>=self.activities.count
{
返回单元
}
让activity=self.activities[indexPath.row]
cell.activity=活动
cell.name.text=activity.name
如果activity.distance!=零
{
cell.distance.text=字符串(格式:“%.2f km”,activity.distance!.floatValue/1000)
}
如果activity.elevationGain!=零
{
cell.elevation.text=字符串(格式:“%d m”,Int(activity.elevationGain!))
}
如果activity.date!=nil
{
cell.date.text=DateHelper.getDateString(日期:activity.date!)
}
//地图
如果activity.map!=nil&&activity.map!.summary!=nil
{
var coordinates=PolylineDecoder.decode(activity.map!.summary!)
DispatchQueue.main.async
{
//清除旧覆盖层
cell.map.removeOverlays(cell.map.overlays)
cell.map.delegate=self
设polyline=MKPolyline(坐标:&coordinates,计数:coordinates.count)
cell.map.add(多段线)
cell.map.setRegion(mkCoordinatereRegionformPrect(polyline.boundingMapRect),动画:false)
}
}
返回单元
}
重写func tableView(tableView:UITableView,didSelectRowAt indexPath:indexPath)
{
让index=indexath.row
如果索引MKOverlayRenderer
{
设polylineRenderer=MKPolylineRenderer(覆盖:覆盖)
polylineRenderer.strokeColor=UIColor.red
polylineRenderer.lineWidth=1
回程折线器
}

我在使用地图视图时遇到了同样的问题。不知道如何修复。当您在设备上而不是从Xcode启动应用程序时,是否会发生这种情况?