如何解决Swift中的消失/不可见/空UITableViewCells问题?
  我有两个ViewControllers ,一个是GoalsViewController ,另一个是AddNewGoalViewController 。 
  GoalsViewController对于删除目标(单元格)和添加新目标(单元格)很有用。  有一个UITableView和一个按钮, 添加新的目标 。  当用户按下Add new Goal按钮时,它将传递给AddNewGoalViewController 。  在AddNewGoalViewController用户将选择锻炼,通知(他们希望被通知多少次),以及他们想要跑步,走路或做其他工作。 
我检查了一个教程(点击“tutorial”来检查它),这很有帮助。 问题在于它正在实现空单元。 下载我的项目以更好地检查它。
编辑:花了很多时间看你的项目后,我发现了这个问题。
点击你的Main.Storyboard文件。 点击文件检查器。 取消选中大小类。 完成。 您的项目有效!
这似乎是一个XCode错误。 如果再次检查Size Classes,你的项目仍然可以工作。
因此,修正是取消选中,然后检查Main.storyboard文件的文件检查器中的Size Classes。
NONETHELESS:我的语法建议仍然有效,它使得代码更简洁:
那么,你检查了练习的解决方案吗?
页面末尾有链接;)
第一差异:
var workouts = [Workout]()
var numbers = [Workout]()
func loadSampleMeals() {
    let workouts1 = Workout(name: "Run", number: "1000")!
    let workouts2 = Workout(name: "Walk", number: "2000")!
    let workouts3 = Workout(name: "Push-Ups", number: "20")!
    workouts += [workouts1, workouts2, workouts3]
    numbers += [workouts1, workouts2, workouts3]
}
应该:
var workouts = [Workout]()
func loadSampleMeals() {
    let workouts1 = Workout(name: "Run", number: "1000")!
    let workouts2 = Workout(name: "Walk", number: "2000")!
    let workouts3 = Workout(name: "Push-Ups", number: "20")!
    workouts += [workouts1, workouts2, workouts3]
}
第二差异:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    // Table view cells are reused and should be dequeued using a cell identifier.
    let cellIdentifier = "DhikrTableViewCell"
    let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier, forIndexPath: indexPath) as! GoalsTableViewCell
    // Fetches the appropriate meal for the data source layout.
    let dhikr = workouts[indexPath.row]
    let number = numbers[indexPath.row]
    cell.nameLabel.text = dhikr.name
    cell.numberLabel.text = number.number
    //cell.photoImageView.image = dhikr.photo
    //cell.ratingControl.rating = dhikr.rating
    return cell
}
应该:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    // Table view cells are reused and should be dequeued using a cell identifier.
    let cellIdentifier = "DhikrTableViewCell"
    let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier, forIndexPath: indexPath) as! GoalsTableViewCell
    // Fetches the appropriate meal for the data source layout.
    let dhikr = workouts[indexPath.row]
    cell.nameLabel.text = dhikr.name
    cell.numberLabel.text = dhikr.number
    //cell.photoImageView.image = dhikr.photo
    //cell.ratingControl.rating = dhikr.rating
    return cell
}
PS:
class Workout {
    // MARK: Properties
    var name: String
    //var notifications: Int
    var number: Int
    // MARK: Initialization
    init?(name: String, number: Int) {
        // Initialize stored properties.
        self.name = name
        //self.notifications = notifications
        self.number = number
        // Initialization should fail if there is no name or if the rating is negative.
        if name.isEmpty || number < 0{
            return nil
        }
    }
}
  number永远不会<0,也许你的意思是== 0 ? 
上一篇: How to fix the Disappearing/Invisible/Empty UITableViewCells issue in Swift?
