【问题标题】:get output frames failed, state 8196获取输出帧失败,状态 8196
【发布时间】:2018-10-08 21:12:41
【问题描述】:

当我尝试自定义一个 tableView 单元格时,我发现了这个错误。

“获取输出帧失败,状态 8196”

我只是不知道这是来自领域或来自我的自定义 tableView 单元格的错误。

class StudentTableViewController: UITableViewController {

    let realm = try! Realm()
    var student: Results<StudentName>?
    var selectedClass: ClassName? {
        didSet {
            load()
        }
    }
    var selected: String = ""

    override func viewDidLoad() {
        super.viewDidLoad()
        navigationController?.title = selected
        tableView.register(StudentTableViewCell.self, forCellReuseIdentifier: "studentName")
    }

    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return student?.count ?? 1
    }

    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "studentName", for: indexPath) as! StudentTableViewCell
        cell.name.text = student?[indexPath.row].name ?? "There are no student in this class"
        cell.number.text = "\(student?[indexPath.row].studentNumber ?? 0)"
        return cell
    }
    func load() {
        student = selectedClass?.studentNames.sorted(byKeyPath: "studentNumber", ascending: true)
        tableView.reloadData()
    }
}

我认为当我使用 Xcode 9 和 Swift 4.1 时它确实有效,但现在在 Xcode 10 中它不起作用,因为它只显示这个错误和表格视图的整个空白页。

【问题讨论】:

  • 您在使用情节提要吗?哪一行代码抛出了这个错误?
  • 是的tableview故事板
  • 网络电话在哪里? “获取输出帧”指的是 BoringSSL 方法:nw_protocol_boringssl_get_output_frames

标签: swift uitableview realm


【解决方案1】:

当您使用 Realm 时,即使您打算仅离线使用它,也可以在控制台中打印此错误。

当应用程序在调试模式下运行时,它将匿名收集分析,如以下答案所述:Realm Swift use locally only, however it still tries to connect online

要停止错误,请单击编辑方案,并添加环境变量REALM_DISABLE_ANALYTICS,并将其设置为YES,如图所示:

Environment variable screen

【讨论】:

    【解决方案2】:

    如果您使用 Storyboard,则不应调用 tableView.register,而应简单地为 Storyboard 中的原型单元格设置 reuseIdentifier

    【讨论】:

    • 请问我该如何以及在哪里设置?
    • @JoanneFsadni 在情节提要中,您可以在其中将原型单元格添加到表格视图中。
    【解决方案3】:

    如果单元格有单独的 .xib 文件,则应使用:

    tableView.register(nib: UINib?, forCellReuseIdentifier: String)
    

    换句话说,您的单元格的注册将是这样的:

    self.tableView.register(UINib(nibName: "your cell nib name", bundle: nil), forCellReuseIdentifier: "your cell identifier")
    

    如果您已将单元格放置在位于故事板中的控制器内的 tableview 中,那么您不需要注册您的单元格,并且正如@Dávid Pásztor 所提到的,请确保将单元格标识符添加到故事板中的单元格中

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-04-21
      • 1970-01-01
      • 2014-09-23
      • 2018-10-15
      • 2013-10-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多