【问题标题】:"Connection interrupted" Communications error on iOS 9iOS 9 上的“连接中断”通信错误
【发布时间】:2017-12-01 22:59:33
【问题描述】:

谁能帮我弄清楚我在运行我的应用程序时遇到的以下错误?

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

        let customCell = tableView.dequeueReusableCell(withIdentifier: "tableViewCell", for: indexPath) as! CustomTableViewCell
        customCell.selectionStyle = .none
        let dictionaryAtIndex = contentArray[indexPath.row] as Dictionary <String, Any>

        customCell.activityIndicator .isHidden = false
        customCell.activityIndicator .startAnimating()
        customCell.imgView.sd_setImage(with: URL(string: imageURL!), completed: { (image, error, cacheType, url) in
            customCell.activityIndicator .stopAnimating()
            customCell.activityIndicator .isHidden = true
            print("image downloaded %@",image ?? "")
        })
    return customCell
}

每次滚动时它都会崩溃。获取通信错误:{ count = 1, contents = "XPCErrorDescription" => { length = 22, contents = "Connection interrupted" } }> Xcode 7 (iOS 9) 通信错误: .请尽快帮助我。

【问题讨论】:

  • 您可以尝试加载本地图像吗? ...只是为了测试

标签: ios swift ios9 ios10 sdwebimage


【解决方案1】:

可能您正在超载 SDWebImage 下载器。

您可以尝试调整图像下载器以更改最大并发下载数或下载超时

在 Swift 3 (SDWebImage V 4.0.0) 中

SDWebImageManager.shared().imageDownloader?.maxConcurrentDownloads = yourValue

SDWebImageManager.shared().imageDownloader?.downloadTimeout = yourTimeout

【讨论】:

  • 在iOS 10或更高版本没有任何问题。该问题仅在iOS 10以下版本出现。
  • XPC 是 Apple 的进程间通信 (IPC) 系统。某些功能(可能与图像下载有关)由一个单独的后台程序处理 - 该后台程序在后台运行。连接中断意味着 IPC 连接由于某种原因被中断。也许花了太长时间,也许时机不好,守护程序或您的应用程序需要紧急做其他事情。该系统由操作系统提供。所以我并不惊讶它只发生在特定版本上。
  • 您能验证您的应用程序使用的内存量吗?如果您的系统内存不足,则可能会产生此类问题。
  • 它有 53 MB 大小,还有 10.2 GB 可用空间。
  • 您应该验证应用程序在执行期间使用的内存,而不是应用程序本身的大小。您可以使用 XCode Debug navigator 提供的内存分析工具收集此信息
【解决方案2】:

customCell.imgView.sd_setImage(with: URL(string: imageURL!) 这一行来看,崩溃可能是因为您尝试使用SDWebImage 加载非常大的图像或大量图像。我的建议是预先在后台下载所有图像,将它们保存到您的文件夹中,然后将它们加载到您UITableView

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-12-18
    • 1970-01-01
    • 2015-12-17
    • 2015-08-19
    • 1970-01-01
    • 1970-01-01
    • 2015-02-06
    相关资源
    最近更新 更多