gpt4 book ai didi

ios - UITableView 不显示单元格

转载 作者:搜寻专家 更新时间:2023-11-01 06:23:39 27 4
gpt4 key购买 nike

我正在使用 Xcode 6 Swift 和 Storyboard 来构建一个 IOS 应用程序。下面是我的 File.swift 中的内容:

import Foundation

struct December {
let name : String
}

然后,在我的 View Controller 中,我有:

import UIKit

class ViewControllerDecember: UITableViewController {

var december = [December] ()


override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.

self.december = [December(name: "1"), December(name: "2"), December(name: "3"), December(name: "4"), December(name: "5"), December(name: "6"), December(name: "7"), December(name: "8"), December(name: "9"), December(name: "10"), December(name: "11"), December(name: "12"), December(name: "13"), December(name: "14"), December(name: "15"), December(name: "16"), December(name: "17"), December(name: "18"), December(name: "19"), December(name: "20"), December(name: "21"), December(name: "22"), December(name: "23"), December(name: "24"), December(name: "25"), December(name: "26"), December(name: "27"), December(name: "28"), December(name: "29"), December(name: "30"), December(name: "31")]

}

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

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

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

var de1 : December

de1 = december[indexPath.row]

cell.textLabel?.text = de1.name

return cell


}
}

当我运行该应用程序时,它会显示表格 View ,但不会显示任何单元格数据。我错过了什么?

最佳答案

您可能只需要将原型(prototype)单元格标识符设置为“单元格”。

转到 Storyboard ,单击您的表格 View ,单击属性。

通过将其从 0 更改为 1 来给自己一个原型(prototype)单元格。

点击原型(prototype)单元格。将“标识符”属性设置为“单元格”。

关于ios - UITableView 不显示单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28511473/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com