首页 > 解决方案 > 从情节提要将类附加到 tableview 时出现问题

问题描述

我正在开发一个具有用户创建部分的应用程序,我在情节提要的表格视图中创建了创建帐户。

如果我当时只是运行模拟器,我会看到所有的 tableview,一切都很好。但是一旦我将一个扩展 UITableViewController 的类附加到它,并且我在模拟器中运行所有内容,屏幕就是空的,没有字段。我究竟做错了什么 ?我需要寻找什么?

如果我空运行它,我会在模拟器中看到一切都很好>

在此处输入图像描述

但是一旦我添加了课程,我什么都看不到,但是空字段>

在此处输入图像描述

谢谢

标签: iosswiftxcode

解决方案


通过修改我的 Tableview 方法来修复它:

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        // #warning Incomplete implementation, return the number of rows
        print ("section: ", section)
        if (section == 0) {
            return 4

        } else if (section == 1) {
            return 1

        } else if (section == 2) {
            return 4

        } else if (section == 3) {
            return 2

        } else if (section == 4) {
            return 1

        } else if (section == 5) {
            return 3

        } else if (section == 6) {
            return 1

        } else if (section == 7) {
            return 1

        } else {
            return 0
        }

    }

推荐阅读