[英]TableView is showing blank cells
好的,所以我的應用程序運行良好,一段時間后,單元格不再起作用。
運行該應用程序時,它顯示3個單元格,但內部沒有任何信息
var names = ["Bob", "Bill", "Billy"] func numberOfSectionsInTableView(tableView: UITableView) -> Int { return 1 } func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return names.count } func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! NamesCell cell.name.text = self.names[indexPath.row] return cell }
NamesCell(自定義單元格)
@IBOutlet weak var name: UILabel! override func awakeFromNib() { super.awakeFromNib() // Initialization code } override func setSelected(selected: Bool, animated: Bool) { super.setSelected(selected, animated: animated) // Configure the view for the selected state }
好的,因此我清除了約束,然后將相同的約束重新添加到單元格標簽上,它可以正常工作。 很奇怪?
刪除約束並再次添加它們,這是約束的問題。 您的代碼還可以。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.