iOS swift-数据未显示在自定义视图控制器的表视图中

iOS swift-数据未显示在自定义视图控制器的表视图中,ios,cocoa-touch,Ios,Cocoa Touch,我试图在表视图中显示一些简单的数据,但我只看到没有数据的表行。上课时间到了 class DoctorInfoViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { @IBOutlet var outerTableView: UITableView! var items: [String] = ["We", "Heart", "Swift"] override func viewDidLo

我试图在表视图中显示一些简单的数据,但我只看到没有数据的表行。上课时间到了

class DoctorInfoViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {

@IBOutlet var outerTableView: UITableView!


var items: [String] = ["We", "Heart", "Swift"]

override func viewDidLoad() {
    super.viewDidLoad()

    // Do any additional setup after loading the view.
    print("DoctorInfoViewController is called.")
    self.outerTableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "cell")
}


func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return self.items.count;
}

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell:UITableViewCell = self.outerTableView.dequeueReusableCellWithIdentifier("cell")! as UITableViewCell

    cell.textLabel?.text = self.items[indexPath.row]

    return cell
}

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    print("You selected cell #\(indexPath.row)!")
}
}

我的故事板有一个基于选项卡的视图。底部有5个选项卡。与每个选项卡关联的视图是自定义视图控制器。其中之一是与此DoctorInfo视图控制器关联的“医生信息”。当我启动它时,我只看到表行,但没有数据


我添加了图像。我是否做错了什么,或者是否有任何属性需要检查?谢谢。

您需要在某个时候在表视图上调用
reloadData()
?顺便说一句:如果您使用的是原型单元格,请不要注册该单元格。如果场景中只有一个表视图,请不要使用
cellforrowatinexpath
中的插座,请使用传递的
tableView
实例。谢谢您的评论。我应该在哪里调用reloadData()?在本例中,在
viewDidLoad
的末尾。我推荐了寄存器代码,并将其替换为self.outerTableView.reloadData()。但它的行为是一样的。我猜这与刷新表视图有关。这应该是Swift 3吗?如果是,则数据源委托方法的签名错误。