|
@@ -17,12 +17,13 @@ class NCEmptyDataSet: NSObject {
|
|
super.init()
|
|
super.init()
|
|
|
|
|
|
self.collectionView = collectionView
|
|
self.collectionView = collectionView
|
|
|
|
+
|
|
if let emptyView = UINib(nibName: "NCEmptyView", bundle: nil).instantiate(withOwner: self, options: nil).first as? NCEmptyView {
|
|
if let emptyView = UINib(nibName: "NCEmptyView", bundle: nil).instantiate(withOwner: self, options: nil).first as? NCEmptyView {
|
|
|
|
|
|
self.emptyView = emptyView
|
|
self.emptyView = emptyView
|
|
|
|
|
|
emptyView.frame = CGRect(x:0, y: 0, width:300, height:300)
|
|
emptyView.frame = CGRect(x:0, y: 0, width:300, height:300)
|
|
- //emptyView.isHidden = true
|
|
|
|
|
|
+ emptyView.isHidden = true
|
|
emptyView.translatesAutoresizingMaskIntoConstraints = false
|
|
emptyView.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
|
|
emptyView.emptyImage.image = image
|
|
emptyView.emptyImage.image = image
|
|
@@ -31,19 +32,20 @@ class NCEmptyDataSet: NSObject {
|
|
|
|
|
|
collectionView.addSubview(emptyView)
|
|
collectionView.addSubview(emptyView)
|
|
|
|
|
|
- emptyView.centerXAnchor.constraint(equalTo: collectionView.centerXAnchor, constant: 0).isActive = true
|
|
|
|
- emptyView.topAnchor.constraint(equalTo: collectionView.topAnchor).isActive = true
|
|
|
|
|
|
+ let constantY: CGFloat = (collectionView.frame.height - emptyView.frame.height) / 2 - 100
|
|
|
|
+
|
|
|
|
+ emptyView.centerXAnchor.constraint(equalTo: collectionView.centerXAnchor).isActive = true
|
|
|
|
+ emptyView.topAnchor.constraint(equalTo: collectionView.topAnchor, constant: constantY).isActive = true
|
|
|
|
|
|
- emptyView.layoutIfNeeded()
|
|
|
|
|
|
+ //emptyView.layoutIfNeeded()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- func reload() {
|
|
|
|
- let items = collectionView?.numberOfItems(inSection: 0)
|
|
|
|
- if items == 0 {
|
|
|
|
|
|
+ func numberOfItemsInSection(_ numberItems: Int) {
|
|
|
|
+ if numberItems == 0 {
|
|
emptyView?.isHidden = false
|
|
emptyView?.isHidden = false
|
|
} else {
|
|
} else {
|
|
- //emptyView?.isHidden = true
|
|
|
|
|
|
+ emptyView?.isHidden = true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|