我試圖建立一個空的數據集DZNEmptyDataSet,而我的tableview勢必給RX變量DZNEmptyDataSet與RxSwift中的tableview綁定不兼容。有沒有人能夠使它工作?
let Chats = Variable(Section).
Chats.asObservable()
.bind(to: tableView.rx.items(dataSource: dataSource))
和我DZN代碼如下:
tableView.emptyDataSetSource = self
tableView.emptyDataSetDelegate = self
func title(forEmptyDataSet scrollView: UIScrollView) -> NSAttributedString? {
let str = "Welcome"
let attrs = [NSFontAttributeName: UIFont.preferredFont(forTextStyle: UIFontTextStyle.headline)]
return NSAttributedString(string: str, attributes: attrs)
}
func description(forEmptyDataSet scrollView: UIScrollView) -> NSAttributedString? {
let str = "Tap the button below to add your first grokkleglob."
let attrs = [NSFontAttributeName: UIFont.preferredFont(forTextStyle: UIFontTextStyle.body)]
return NSAttributedString(string: str, attributes: attrs)
}
的問題是,即使當Chats爲空時,tableview的空數據集不會顯示。如果我刪除綁定功能,它會顯示。我想知道是否有人能夠讓這兩個人共存?
是的,它沒有工作時綁定到rxdatasource表。我猜它的rxdatasource與它不兼容。我不得不在桌子上放置一個可觀察的東西,如果它叫做refreshemptydataset。 – Ryan