我希望创建一个与此类似的空数据集。不是它的外观或任何东西,而是只是了解空数据集的一般概念。我不确定如何做到这一点,并且我一直想在不使用任何 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
}
}
最佳答案
您展示的和许多其他人使用的那个
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/