簡體   English   中英

情節提要中的自定義表格視圖單元格布局似乎無效

[英]custom Table View Cell layout in storyboard seems invalid

我在情節提要中自定義表格視圖單元格,以使單元格中的標簽居中。

但似乎沒有任何感情。

我的情節提要是這樣的:

在此處輸入圖片說明

實際上是這樣的:

在此處輸入圖片說明

我只在這樣的代碼中設置標簽的文本:

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "Movie", for: indexPath) as! ArchiveTableViewCell
    cell.showChineseTitle.text = chineseTitleArray[indexPath.row]

    return cell
}

為什么?

提前致謝!!!

嘗試添加:

cell.showChineseTitle.textAlignment = .center

因為您沒有為UILable正確設置文本對齊方式。 但是只能設置它在單元格中的位置。

刪除前導和頂部約束,並設置寬度和高度約束,以使標簽在單元格中居中。 將標簽的textAlignment屬性設置為center。

在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM