ios - 在 Swift 3 中出列可重用单元非常慢

标签 ios swift uitableview swift3

单元格出队需要 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.4708.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 操作。就是这样。

enter image description here

究竟是什么导致它需要这么长时间才能使一个单元格出队?是关于系统组容器的另外两个系统 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

enter image description here

只有在调试应用程序时才会遇到这个问题。 这将在真实设备上运行良好。

关于ios - 在 Swift 3 中出列可重用单元非常慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45318181/

相关文章:

php - 我可以在 Swift 的 header 中使用 token 来授权数据库连接吗?

ios - 在非游戏应用程序中使用 Sprite 来提高静态视网膜图形的可管理性是否明智?

swift - 将图片上传到 Firebase 存储并显示为个人资料图片

ios - 在tableview中删除一行

ios - iOS 版本的 Twitter 个人资料屏幕是如何构建的?

objective-c - 如何使用 UIPopOverController 制作一个在 iPhone 上使用 ImagePicker 的 iPhone 应用程序?

ios - 保存最后一个 datePicker 选择

swift - 当我从 firebase 存储上传新图像时,imageView 不会更改图像

swiftc 失败,退出代码为 1

ios - 如果我有多个部分,如何放置不同的单元格值?