Swift 表格视图滞后(即使在移除手势识别器后)

Swift 表格视图滞后(即使在移除手势识别器后),swift,uitableview,tableview,cell,lag,Swift,Uitableview,Tableview,Cell,Lag,目前,我有一个表视图,当有多个单元格时,它会滞后。当只有一个单元时,它运行平稳;但是,当填充多个单元格时,表格视图会有一种缓慢的感觉,有时会出现口吃,并且不太平滑。我删除了手势识别器,改为didSelectRowAt,但是单元格中仍然存在延迟。以下是加载单元格时的代码: public func tableView(\utableview:UITableView,cellForRowAt indexath:indexPath)->UITableView单元格{ 如果queryComplete==t

目前,我有一个表视图,当有多个单元格时,它会滞后。当只有一个单元时,它运行平稳;但是,当填充多个单元格时,表格视图会有一种缓慢的感觉,有时会出现口吃,并且不太平滑。我删除了手势识别器,改为didSelectRowAt,但是单元格中仍然存在延迟。以下是加载单元格时的代码:

public func tableView(\utableview:UITableView,cellForRowAt indexath:indexPath)->UITableView单元格{
如果queryComplete==true{
如果DisplayConva==true{
让cell=tableView.dequeueReusableCell(标识符为:“messageCell”,for:indepath为indepath)为!messageTableViewCell
cell.profileImage.image=nil
cell.selectionStyle=UITableViewCell.selectionStyle.none
var convalcontent:messagesViewController.conva
convalContent=convalist[indexPath.row]
convalcontent.itemHeroID=“\(字符串(描述:convalcontent.convalid))”
cell.name.海洛因=“\(字符串(描述:convalcontent.convalid))”
cell.lastMessage.text=convolcontent.lastMessage
cell.backgroundColor=UIColor.clear
cell.postText.text=convalcontent.postContent
如果convoContent.revealedBool==true{
cell.profileImage.ishiden=false
cell.profileImage.heroID=“\(字符串(描述:convalContent.convalid))”
cell.name.text=convalcontent.name
cell.timer.ishiden=true
如果convalcontent.profileImage==“nil”| convalcontent.profileImage==nil{
让url=url(字符串:https://firebasestorage.googleapis.comasdjfjaisfdji")
let processor=RoundCornerImageProcessor(cornerRadius:cell.profileImage.frame.size.width/2)
cell.profileImage.kf.setImage(带:url,占位符:nil,选项:[.processor(processor)])
}
否则{
让url=url(字符串:convolcontent.profileImage!)
let processor=RoundCornerImageProcessor(cornerRadius:cell.profileImage.frame.size.width/2)
cell.profileImage.kf.setImage(带:url,占位符:nil,选项:[.processor(processor)])
}
}
否则{
cell.profileImage.ishiden=true
cell.timer.ishiden=false
cell.timer.isUserInteractionEnabled=false
cell.timer.海洛因=“\(字符串(描述:convalContent.convalid))”
让postDuration=convalcontent.timeOfDeletion!-Int(convalcontent.time!)
设currentTime=Date().TimeIntervalence1970*1000
让差=Int(四舍五入(双精度)(convalcontent.timeOfDeletion!-Int(currentTime)))
设日期=日期(timeIntervalSinceNow:TimeInterval(差/1000))
cell.name.text=字符串(timeToDelete(日期:日期为NSDate,数字日期:false))
设amountOfCircleCovered=(Double((convalcontent.timeOfDeletion!)-Int(currentTime))/Double(postDuration))*100
var timerColor:UIColor?
开关量断路器{

案例0.基本上,用户界面大大降低了性能。我关闭了部分填充圆的png图像的饼图时间CA层,并删除了所有英雄动画。结果,应用程序和桌面视图变得更加平滑。

与手势识别器无关。你在cellForRow或o中花费了太多时间详细说明图层绘制树,或者两者都详细说明。@马特,你能详细说明一下吗?我如何减少cellForRow的时间或减少图层?我仍然希望有相同的设计,有光泽的视图和计时器动画等等,逻辑仍然是必要的,所以我不确定……Instruments为你提供了分析口吃sc的强大工具滚动动画。苹果有许多关于这个主题的WWDC视频。观看它们!@matt在查看时间分析后,似乎CA Layer Display Quartz Core花费了1.27秒和19%的重量。这是否意味着单元格内的图形是导致延迟的原因?PieSicleModel(值:Double(100-amountOfCircleCovered),颜色:
UIColor(红色:220/255,绿色:220/255,蓝色:220/255,alpha:1)),PieSiceModel(值:Double(amountOfCircleCovered),颜色:timerColor!),
@matt还显示了Pie-Slice层占18.3%的重量。我如何保持这些动画计时器不滞后?