[英]UIPageViewController and AutoLayout: constraints are not applied correctly
[英]Autolayout constraints not applied
要使您的標簽文本完美居中,請刪除
鎖名稱 Lbl.leading =leadingMargin - 8
在此基礎上將其余兩個約束保留為以下工作:
Lock Name Lbl.centerY = superview.centerY
Lock Name Lbl.centerX = superview.centerX
添加這兩個約束:
Lock Name Lbl.width = superview.width /* Or desired width */
Lock Name Lbl.height = superview.height /* Or desired height */
並且不要忘記將標簽文本居中對齊。
對於多行設置編號。 行數為 0 並且將應用以下約束(我始終建議使用它):
Lock Name Lbl.centerX = superview.centerX
Lock Name Lbl.width = superview.width /* Or desired width */
Lock Name Lbl.top = superview.top
Lock Name Lbl.bottom = superview.bottom
當您使用 tableview 時,請在 UITableViewController 類中的 viewdidload 中使用此 tableview 委托函數和一行代碼:
override func viewDidLoad() {
super.viewDidLoad()
tableView.estimatedRowHeight = 200
}
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.