问题:我有一个简单的UITableViewController,想在自定义单元格中显示标签。我创建了一个简单的UITableViewController,其中第1部分的数量和第4行的数量进行了硬编码。在情节提要中,使用新标签自定义单元格,为其指定标识符,并在DemoTableViewCell中映射插座。以下是该代码的所有不同摘要的快照。对我来说,在函数中分配的标签文本仍然无法显示。
class DemoTableViewCell: UITableViewCell {
@IBOutlet weak var demoLabel: UILabel!
}
override func numberOfSections(in tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return 4
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell : DemoTableViewCell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifier", for: indexPath) as! DemoTableViewCell
cell.demoLabel.text = "Override Label"
// Configure the cell...
return cell
}
有人可以让我知道我在做什么错吗?
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句