Swift4滚动UITableview后,动画化UITableview框架是错误的

问题描述

testView是子视图 有testView和view NSLayout

self.view.addSubview(testView)
testView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint(item: testView,attribute: .centerX,relatedBy: .equal,toItem: self.view,multiplier: 1.0,constant: 0.0).isActive = true
NSLayoutConstraint(item: testView,attribute: .centerY,constant: 0.0).isActive = true
self.testWidth = NSLayoutConstraint(item: testView,attribute: .width,constant: 0.0)
self.testWidth.isActive = true
self.testHeight = NSLayoutConstraint(item: testView,attribute: .height,constant: 0.0)
self.testHeight.isActive=true

tblview是UITableview tblview是testView的子视图 有tblview和testView NSLayout

self.testView.addSubview(self.tblView)
self.tblView.translatesAutoresizingMaskIntoConstraints=false
self.tblView.register(NotYetWriteCell.self,forCellReuseIdentifier: "NotYetWriteCellPage")
NSLayoutConstraint(item: tblView,toItem: self.testView,constant: 0.0).isActive = true
NSLayoutConstraint(item: tblView,constant: 0.0).isActive = true

UITableview委托,数据源

func tableView(_ tableView: UITableView,numberOfRowsInSection section: Int) -> Int {
    return 50
}

func tableView(_ tableView: UITableView,cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    print("cell")
    let cell = tableView.dequeueReusableCell(withIdentifier: "NotYetWriteCellPage",for: indexPath) as! NotYetWriteCell
    
    cell.contentView.layoutIfNeeded()
                   
    
    return cell
}
func tableView(_ tableView: UITableView,heightForRowAt indexPath: IndexPath) -> CGFloat {
  
    print(self.tblView.frame.height)
    return self.testView.frame.height/7
    
}

动画动作代码

self.testWidth.isActive = false
self.testHeight.isActive = false

self.testHeight = NSLayoutConstraint(item: testView,multiplier: 0.5,constant: 0.0)
self.testHeight.isActive = true
self.testWidth = NSLayoutConstraint(item: testView,constant: 0.0)
self.testWidth.isActive = true
UIView.transition(with: self.view,duration: 2.0,options: .curveEaseIn,animations: {
    self.testView.layoutIfNeeded()
},completion: { (finish) in
    if finish{
        self.took=true
    }
        
})

解决方法

我的自定义单元格此。

Node

}

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...