Ios UITableView单元格中未显示任何内容

Ios UITableView单元格中未显示任何内容,ios,xcode,swift,uitableview,uisplitviewcontroller,Ios,Xcode,Swift,Uitableview,Uisplitviewcontroller,我正在开发一个应用程序,它需要在五个不同的tableview单元格中显示五个不同的图像。这是我为牢房准备的故事板 这是我在tableviewcontroller中的代码 class MasterViewController: UITableViewController, UITableViewDelegate, UITableViewDataSource { var returnTable = 1 var icons: [String] = ["settings", "calendar

我正在开发一个应用程序,它需要在五个不同的tableview单元格中显示五个不同的图像。这是我为牢房准备的故事板

这是我在tableviewcontroller中的代码

    class MasterViewController: UITableViewController, UITableViewDelegate, UITableViewDataSource {
var returnTable = 1
var icons: [String] = ["settings", "calendar", "classes", "envelope", "grades"]




override func viewDidLoad() {
    super.viewDidLoad()






    // Uncomment the following line to preserve selection between presentations
    // self.clearsSelectionOnViewWillAppear = false

    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem()
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

// MARK: - Table view data source

override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
    // #warning Potentially incomplete method implementation.
    // Return the number of sections.
    return 0
}

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    // #warning Incomplete method implementation.
    // Return the number of rows in the section.


    return icons.count
}


override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! HomeScreenCells


    var image : UIImage = UIImage(named: icons[indexPath.row])!
    cell.icon.image = image


    return cell
}
我还有一个用于tableviewcells的自定义类。另外,我有正确的单元重用标识符。但是,图像仍然没有显示。图像不仅没有出现,而且什么也没有出现。当我改变背景时,模拟器中的背景不会改变。这就是我在模拟器里得到的所有东西


我已经为分割视图控制器正确链接了类。我不知道为什么桌子上什么也没有出现。如果您有任何帮助,我们将不胜感激。

我想您的问题可能是您的节数设置为0。要么将其设置为1,要么完全省略代码块

如上所述,按节数(或所需单元格数)返回1。如果您的自定义单元格类有一个.xib,您还需要注册它,有时在初始化tableview之后

tableView.registerNib( UINib(nibName: "HomeScreenCells", bundle: nil), forCellReuseIdentifier: "Cell")

numberOfSectionsInTableView
设置为
1
。如果表中包含的节数不超过1节,请删除代码。它的可选方法。您的imageview是否连接到IBOutlet。或者图标imageview的大小可能有问题,请尝试更改UIImageView的背景颜色,然后进行检查。将节设置为1会使背景发生变化,但图像仍然不会显示。图标是64x64,图像视图也是如此。我将它连接到cell类中的IBOutlet。