[英]Autolayout issue in UITableviewcell Which has Uitableview as subview
好的,基本上:
首先,您必須使tableView1具有自動調整大小的單元格。 為此,在tableView1類中,您需要在viewDidLoad()方法中添加以下內容:
tableView.rowHeight = UITableViewAutomaticDimension
tableView.estimatedRowHeight = constant-value-here
之后,您需要將以下自動布局約束添加到UITableViewCell子類。
在該方法中,添加以下內容:
tableView2.centerXAnchor.constraint(equalTo: centerXAnchor).isActive = true
tableView2.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true
tableView2.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -8).isActive = true
tableView2.heightAnchor.constraint(greaterThanOrEqualTo: another-constant-value here).isActive = true
還要確保tableView2.translatesAutoresizingMaskIntoConstraints
設置為false
並且不要忘記在tableView子類的init方法中調用setupCell方法。
如果有什么不清楚,請告訴我。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.