Ios 无法将数据填充到表视图中

Ios 无法将数据填充到表视图中,ios,swift,uitableview,Ios,Swift,Uitableview,我是斯威夫特4号。 我无法将数据(在信息数组中)填充到表视图中。 我希望字符串“姓名”、“出生日期”、“性别”、“电话”、“电子邮件”会显示在表视图中,但没有显示任何内容 我已输入“ProfileInfo”作为我的tableViewCell标识符 谢谢 let information = ["Name", "Date of Birth", "Gender", "Phone", "Email"] func tableView(_ tableView: UITableView, numberOfR

我是斯威夫特4号。 我无法将数据(在信息数组中)填充到表视图中。 我希望字符串“姓名”、“出生日期”、“性别”、“电话”、“电子邮件”会显示在表视图中,但没有显示任何内容

我已输入“ProfileInfo”作为我的tableViewCell标识符

谢谢

let information = ["Name", "Date of Birth", "Gender", "Phone", "Email"]

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return information.count
    }

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "ProfileInfo", for: indexPath) as! OTProfileTableViewCell
        cell.label.text = information[indexPath.row]
        return cell
    }

有些东西是OP没有包括的。我假设您正在使用带有
UITableView
UIViewController
子类作为子视图(因为在表上方有另一个视图,这对于
UITableViewController
来说并不那么简单)

如果尚未执行这些操作,请尝试以下操作:

  • 确保将视图控制器指定为
    tableView.dataSource
    。您可以在
    viewDidLoad
    或interface builder中进行设置
  • 在视图控制器中声明与UITableViewDataSource协议的一致性。优选地,在包含协议的所有所需方法的实现的扩展中 正在调用
    tableView(uu1;:cellForRowAt:)
    ,并且正在获取的单元格类型是否正确?在此方法中使用断点进行检查。如果未命中断点,则可能未正确设置表的数据源


    表格视图(uuquofrowsinssection:)中设置断点
    。应始终执行此方法(只要您至少有1节)

    有些东西是OP没有包括的。我假设您正在使用带有
    UITableView
    UIViewController
    子类作为子视图(因为在表上方有另一个视图,这对于
    UITableViewController
    来说并不那么简单)

    如果尚未执行这些操作,请尝试以下操作:

  • 确保将视图控制器指定为
    tableView.dataSource
    。您可以在
    viewDidLoad
    或interface builder中进行设置
  • 在视图控制器中声明与UITableViewDataSource协议的一致性。优选地,在包含协议的所有所需方法的实现的扩展中 正在调用
    tableView(uu1;:cellForRowAt:)
    ,并且正在获取的单元格类型是否正确?在此方法中使用断点进行检查。如果未命中断点,则可能未正确设置表的数据源

    表格视图(uuquofrowsinssection:)中设置断点
    。应始终执行此方法(只要您至少有1节)