gpt4 book ai didi

ios - Swift 空数据集

转载 作者:可可西里 更新时间:2023-11-01 00:59:45 28 4
gpt4 key购买 nike

我希望创建一个与此类似的空数据集。不是它的外观或任何东西,而是只是了解空数据集的一般概念。我不确定如何执行此操作,并且我一直想在不使用任何 cocoapods 的情况下将其植入我的应用程序中。这容易做到吗?我是 Swift 的新手,所以我一直无法弄清楚这一点。我尝试了下面的代码,但有很多错误,我意识到它没有意义。

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if return == 0 {
// Create the empty data set
} else {
return jsonfile["response"]["data"].count
}
}

enter image description here

最佳答案

你展示的那个和许多其他人使用的

https://github.com/dzenbot/DZNEmptyDataSet

在你的例子中也是

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
let count = jsonfile["response"]["data"].count
if count == 0 {
return 1
}
return count

然后在您的 cellForRow: 中返回一个无数据的单元格。

编辑:

internal func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let count = jsonfile["response"]["data"].count
if count == 0 {
return noDataCell
} else {
return normalCell
}
}

关于ios - Swift 空数据集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36575181/

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