获取输出帧失败,状态8196 [英] get output frames failed, state 8196
问题描述
当我尝试自定义tableView单元格时,发现此错误.
When I try to customise a tableView cell, I found this error.
获取输出帧失败,状态8196"
"Get output frames failed, state 8196"
我只是不知道这是领域还是我的自定义tableView单元中的错误.
I just have no idea it is the error from realm or from my customise tableView cell.
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中却没有,因为它只向我显示此错误和表格视图的整个空白页.
I think it did work when I am using Xcode 9 and Swift 4.1 but now in Xcode 10 it doesn't since it only show me this error and whole blank page of table view.
推荐答案
如果该单元格具有单独的.xib文件,则应使用:
If you have a separate .xib file for the cell, you should use:
tableView.register(nib: UINib?, forCellReuseIdentifier: String)
换句话说,您的单元格的注册将是这样的:
In other words the registration of your cell would be something like that:
self.tableView.register(UINib(nibName: "your cell nib name", bundle: nil), forCellReuseIdentifier: "your cell identifier")
如果您已将单元格放置在情节提要中位于控制器内的表格视图中,则无需注册您的单元格,如@DávidPásztor所述,请确保将单元格标识符添加到情节提要中的单元格
If you have placed your cell in the tableview inside the controller that sits in the Storyboard then you do not need to register your cell, and as @Dávid Pásztor mentioned make sure you add the cell identifier to the cell in the Storyboard
这篇关于获取输出帧失败,状态8196的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!