Podľa môjho názoru radič používam UITableView v tom, že každá vlastná bunka načítava údaje z iného poľa, teraz, ak konkrétna bunka nemá údaje, potom sa zobrazuje NO-Data
ale teraz, ak každá bunka nemá údaje, chcem skryť UITableView a ukázať No-Data
image. Môže mi niekto pomôcť.
Práve teraz som myslel počítanie viacerých polí a kontrolu, či je prázdny alebo nie. Myslím si však, že by to nebolo možné riešenie.
Každý, kto má na to lepšie riešenie ???
odpovede:
0 pre odpoveď č. 1Skúste to:-
if self.ary.count == 0 && self.ary1.count == 0 //multiple arrays
{
self.tableview.setBackgroundText(stringValue: "No Data")
}
extension UITableView {
func setBackgroundText(stringValue:String) {
let backgroundLabel = UILabel()
backgroundLabel.textColor = UIColor.blue
backgroundLabel.numberOfLines = 0
backgroundLabel.textAlignment = .center
backgroundLabel.text = stringValue
backgroundLabel.autoresizingMask = [.flexibleWidth, .flexibleHeight]
backgroundLabel.translatesAutoresizingMaskIntoConstraints = true
self.backgroundView = backgroundLabel
self.backgroundView?.backgroundColor = .red
}
func removeBackgroundText() {
self.backgroundView = nil
}
}