单元格出队需要 0.5-1.0 秒,这意味着我的 UITableView 需要超过 2-3 秒才能加载,即使它只有 4 行。
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
var cellid = "NumberCell"
var isnumber = true
if indexPath.row == 0 {
cellid = "TextCell"
isnumber = false
}
NSLog("before dequeue \(indexPath)")
let cell = tableView.dequeueReusableCell(withIdentifier: cellid, for: indexPath) as! TextfieldTableViewCell
NSLog("dequeued")
// ...
return cell
}
直接前后的 NSLog() 语句显示出队时间从 07.47
到 08.38
。
2017-07-25 22:07:07.471898-0700 myapp[10209:4507471] before dequeue [0, 0]
2017-07-25 22:07:07.679715-0700 myapp[10209:4507471] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2017-07-25 22:07:07.683843-0700 myapp[10209:4507471] [MC] Reading from public effective user settings.
2017-07-25 22:07:08.386960-0700 myapp[10209:4507471] dequeued
细胞很简单。它只有一个 UILabel 和一个 UITextField,而 UITextField 有一个 Editing Changed 操作。就是这样。
究竟是什么导致它需要这么长时间才能使一个单元格出队?是关于系统组容器的另外两个系统 NSLog() 吗?
这使我的应用程序几乎无法使用,因为当我尝试转至此 View Controller 时,该应用程序在设置 4 行时似乎锁定了 2-4 秒。
我已经在 Objective-C 中制作了数百个 UITableViewController,但我从未遇到过这个问题。 Swift 3 有什么我遗漏的奇怪之处吗?
最佳答案
2017-07-25 22:07:07.679715-0700 myapp[10209:4507471] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2017-07-25 22:07:07.683843-0700 myapp[10209:4507471] [MC] Reading from public effective user settings.
⚠️ 这是来自 OS Level
的日志。 UITableCell
您可以在 xcode
中禁用不需要的登录。像下面一样
1- 从 Xcode 菜单打开:Product > Scheme > Edit Scheme
2- 在您的环境变量中设置 OS_ACTIVITY_MODE
值集 disable
只有在调试应用程序时才会遇到这个问题。 这将在真实设备上运行良好。
关于ios - 在 Swift 3 中出列可重用单元非常慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45318181/