Swift 空数据集
Swift empty data set
我想创建一个与此类似的空数据集。不是它的外观或任何东西,而是只是了解空数据集的一般概念。我不确定如何执行此操作,并且我一直想在不使用任何 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:
return 一个没有数据的单元格中。
编辑:
internal func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let count = jsonfile["response"]["data"].count
if count == 0 {
return noDataCell
} else {
return normalCell
}
}
我想创建一个与此类似的空数据集。不是它的外观或任何东西,而是只是了解空数据集的一般概念。我不确定如何执行此操作,并且我一直想在不使用任何 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:
return 一个没有数据的单元格中。
编辑:
internal func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let count = jsonfile["response"]["data"].count
if count == 0 {
return noDataCell
} else {
return normalCell
}
}