我試圖做一個UITableView
,可以支持其中有不同的對象/元素。具體而言,這些元素是UITextField
和UISwitch
。原型UITableViewCell與其他對象(UITextField,UISwitch)
第一個問題:
元素顯示不出來。它們被放置在原型cell
中,然後在我設置的class
內構建。我已驗證cell
安裝程序正在工作,因爲我可以更改每個cell
上的文字,但cell
中沒有任何元素。
這裏是構建我的電池現在的代碼:
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int{
return 1
}
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell{
let cell = UITableViewCell(style: UITableViewCellStyle.default, reuseIdentifier: "EmailCell")
return cell
}
問題二(可能伴隨着第一可以解決):
我沒有在訪問信息的方式每個UITextField
或每個UISwitch
。我如何從存在的所有單元獲取這些信息?
在此先感謝您的幫助!
被置'custom'原型細胞的風格? – vadian
您必須顯示您用於「構建班級內單元格」的代碼。此外,您的故事板的屏幕截圖可能會有所幫助。 – naglerrr
看起來你正在嘗試創建一個表單。你可以試試https://github.com/xmartlabs/Eureka – Sweeper