Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift DZNEmptyDataSet没有出现_Swift_Tableview - Fatal编程技术网

Swift DZNEmptyDataSet没有出现

Swift DZNEmptyDataSet没有出现,swift,tableview,Swift,Tableview,我正在创建一个空表视图,并已将DZNEmptyDataSet添加到我的应用程序中。我的表视图显示空数组的内容。但是DZNEmptyDataSet没有出现。 这是我的密码: override func viewDidLoad() { super.viewDidLoad() tableView.dataSource = self tableView.delegate = self tableView.emptyDataSetSource = self tabl

我正在创建一个空表视图,并已将DZNEmptyDataSet添加到我的应用程序中。我的表视图显示空数组的内容。但是DZNEmptyDataSet没有出现。 这是我的密码:

override func viewDidLoad() {
    super.viewDidLoad()
    tableView.dataSource = self
    tableView.delegate = self
    tableView.emptyDataSetSource = self
    tableView.emptyDataSetDelegate = self
    tableView.tableFooterView = UIView()
}
var emptyStrings: [String] = []
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return emptyStrings.count
}



func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
   let cell = tableView.dequeueReusableCell(withIdentifier: "newsIdentifier", for: indexPath)
        cell.textLabel?.text = emptyStrings[indexPath.row]
    return cell

}

您应该使用DZNEmotyDataset类。 例如“Swift 4”


您应该使用DZNEmotyDataset类。 例如“Swift 4”


您是否设置了
DZNEmptyDataSet
titleForEmptyDataSet
?是否设置了
DZNEmptyDataSet
titleForEmptyDataSet
    func title(forEmptyDataSet scrollView: UIScrollView) -> NSAttributedString? {
        let str = "Empty Name"
        let attrs = [NSAttributedStringKey.font: UIFont.preferredFont(forTextStyle: UIFontTextStyle.headline)]
        return NSAttributedString(string: str, attributes: attrs)
    }

    func description(forEmptyDataSet scrollView: UIScrollView) -> NSAttributedString? {
        let str = "Empty Title"
        let attrs = [NSAttributedStringKey.font: UIFont.preferredFont(forTextStyle: UIFontTextStyle.body)]
        return NSAttributedString(string: str, attributes: attrs)
    }

    func image(forEmptyDataSet scrollView: UIScrollView) -> UIImage? {
        return UIImage(named: "emptyImage")
    }