0
好的,所以我的应用程序运行良好,过了一段时间,单元格不再工作。TableView显示空白单元格
- 的的tableView被连接到数据源和代表
- 当运行该应用程序,控制台正在打印阵列
内的所有值,其示出了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 }
可以请你提供你所得到的截图吗,还可以放一行cell.backgroundColor = UIColor.redColor() –
什么是你的代码中的NamesCell?这是您创建的自定义类吗? –
检查名称标签的高度,可能为零。如果缺失,请在故事板中设置行高。 – MShah