Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/98.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UITableView在构建时滞后_Ios_Swift_Performance_Uitableview_Snapkit - Fatal编程技术网

Ios UITableView在构建时滞后

Ios UITableView在构建时滞后,ios,swift,performance,uitableview,snapkit,Ios,Swift,Performance,Uitableview,Snapkit,我需要调试一个性能问题的帮助 概述 我有两个ViewControllerA和BA按下B上的ui按钮单击B包含UITableView 问题 当我点击AUI中的UI按钮时,UI冻结1-2秒,然后出现B。当我从B中删除UITableView时,推送操作会顺利进行 实施 建筑单元(我将标签留空): 建筑桌面视图 tableView = UITableView() tableView.customize(cellClasses: [FeedWallCell.self]) view.addSubview(t

我需要调试一个性能问题的帮助

概述 我有两个ViewController
A
B
<代码>A按下
B
上的
ui按钮
单击<代码>B包含
UITableView

问题 当我点击
A
UI中的
UI按钮时,UI冻结1-2秒,然后出现
B
。当我从
B
中删除
UITableView
时,推送操作会顺利进行

实施 建筑单元(我将标签留空):

建筑桌面视图

tableView = UITableView()
tableView.customize(cellClasses: [FeedWallCell.self])
view.addSubview(tableView)
tableView.snp.makeConstraints {
    $0.edges.equalToSuperview()
}
extension UITableView {

    func customize(cellClasses: [IdentifiableTableViewCell.Type] = [],
                   headerFooterClasses: [IdentifiableTableViewHeaderFooterView.Type] = [],
                   datasource: UITableViewDataSource? = nil,
                   delegate: UITableViewDelegate? = nil) {

        backgroundColor = .clear
        separatorStyle = .none
        keyboardDismissMode = .interactive

        estimatedRowHeight = 60
        rowHeight = UITableViewAutomaticDimension

        estimatedSectionHeaderHeight = 60
        sectionHeaderHeight = UITableViewAutomaticDimension

        estimatedSectionFooterHeight = 60
        sectionFooterHeight = UITableViewAutomaticDimension

        self.dataSource = datasource
        self.delegate = delegate

        register(cellClasses: cellClasses)
        register(headerFooterClasses: headerFooterClasses)
    }
}
tableview的自定义方法

tableView = UITableView()
tableView.customize(cellClasses: [FeedWallCell.self])
view.addSubview(tableView)
tableView.snp.makeConstraints {
    $0.edges.equalToSuperview()
}
extension UITableView {

    func customize(cellClasses: [IdentifiableTableViewCell.Type] = [],
                   headerFooterClasses: [IdentifiableTableViewHeaderFooterView.Type] = [],
                   datasource: UITableViewDataSource? = nil,
                   delegate: UITableViewDelegate? = nil) {

        backgroundColor = .clear
        separatorStyle = .none
        keyboardDismissMode = .interactive

        estimatedRowHeight = 60
        rowHeight = UITableViewAutomaticDimension

        estimatedSectionHeaderHeight = 60
        sectionHeaderHeight = UITableViewAutomaticDimension

        estimatedSectionFooterHeight = 60
        sectionFooterHeight = UITableViewAutomaticDimension

        self.dataSource = datasource
        self.delegate = delegate

        register(cellClasses: cellClasses)
        register(headerFooterClasses: headerFooterClasses)
    }
}
轮廓 简单推送需要600+毫秒

环境
iOS11、Xcode9、iPhone6

确保在弹出B deinit()时调用,冻结可能是由于内存泄漏。将deinit()放在两个控制器中。不,即使是第一次按下冻结按钮。因此,内存中没有其他
B
。是否为RowAtIndexPath委托添加了Heights?否,我使用的是
tableview.rowHeight
属性。如果您将SnapKit用于自动布局,请尝试在新的fresh项目中实现相同的功能,而不使用SnapKit,我的意思是使用interface builder进行本机自动布局,并在同一设备中查看该应用程序的性能。