Ios UITableView在构建时滞后
我需要调试一个性能问题的帮助 概述 我有两个ViewControllerIos 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
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进行本机自动布局,并在同一设备中查看该应用程序的性能。