本文介紹了故事板中的自定義 uitableviewcells的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
限時送ChatGPT賬號..
我想我已經完成了所有步驟,但我一定遺漏了一些東西,因為我無法將單元格中的標簽與代碼建立聯系.
I think I got all the steps down but I must be missing something because I can't make a connection from the labels in the cell to the code.
這就是我正在做的事情:
Here's what I'm doing:
- 將單元格樣式設置為自定義
- 將一些標簽拖到原型單元格上.
- 向項目中添加一個新文件并使其成為 UITableViewCell 的子類
- 在我嘗試自定義的單元格的身份檢查器中,我將其類設置為我剛剛創建的新類.
- 嘗試控制從單元格上的標簽拖動到我剛剛創建的類的頭文件以設置 IBOutlet,但它不會讓我這樣做.
我錯過了什么?
推薦答案
將標簽聲明為自定義單元格類中的屬性.在表格視圖控制器中,alloc
或 dequeue
將單元格作為您的自定義類型,而不是作為 UITableViewCell
.在 Xcode 故事板中,控制從單元格本身(例如,最右下角)拖動到單元格中的標簽以連接插座.
Declare the label as a property in the custom cell class. In the table view controller, alloc
or dequeue
the cell as your custom type, not as UITableViewCell
. In the Xcode storyboard, control drag from the cell itself (for example, the far bottom right corner) to the label that is in the cell to connect the outlet.
這篇關于故事板中的自定義 uitableviewcells的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!