我有这个表和单元格
tableView = UITableView()
tableView.dataSource = self
tableView.delegate = self
tableView.allowsSelection = false;
tableView.estimatedRowHeight = 200
tableView.rowHeight = UITableViewAutomaticDimension
var postTexts = ["Nirvana"]
var posters = ["Champagnepapi"]
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return postTexts.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = UITableViewCell()
let ProfilePicture = UIImageView(frame: CGRect(x:19, y: 14, width: 50, height: 50))
ProfilePicture.image = #imageLiteral(resourceName: "cole")
ProfilePicture.layer.cornerRadius = 25
ProfilePicture.layer.masksToBounds = true
let username = UILabel(frame: CGRect(x: 80, y: 14, width: 300, height: 30))
username.text = posters[indexPath.row]
let postText = UITextView(frame: CGRect(x:75,y:40,width:200,height:200))
postText.text = "I rather be dead than cool - Kurt Cobain"
let border = UIView(frame: CGRect(x:0,y:150,width:350,height:1))
border.backgroundColor = UIColor(r: 217, g: 221, b: 219)
cell.addSubview(ProfilePicture)
cell.addSubview(username)
cell.addSubview(postText)
cell.addSubview(border )
return cell
}
如何为我的细胞获得自动高度?