ViewPlaceholder
UITableView and UICollectionView placeholders views in Swift for state like:
- no internet connection
- no data
- loading
- none - just black white view
Is easy to implement, just drag and drom into your project.
Getting Started
Download repository and run on the simulator. Application simulate network requests with different responses. Refresh for simulate requests.
Installing
-
Open project
-
Drag and drop ViewPlaceholder folder into your project
-
Set in your code
final class FirstViewController: UIViewController {
@IBOutlet var tableview: UITableView?
fileprivate lazy var emptyPlaceholder = ViewPlaceholder(frame: CGRect.zero).onRetry { [weak self] in self?.refreshData() }
override func viewDidLoad() {
super.viewDidLoad()
tableview?.backgroundView = emptyPlaceholder
/* or
someCollectionView.backgroundView = emptyPlaceholder
*/
loadDataFromBackEnd()
}
}
And then, on your downloading method
extension FirstViewController {
func loadDataFromBackEnd() {
/*
...
your code here
...
on callback from networking manager handle raspose:
self.emptyPlaceholder.handleRespunse(status: success, total: total)
*/
networking.send(.someRequest) { (success, totalItems) in
/*
... your code here
*/
self.emptyPlaceholder.handleRespunse(status: success, total: total)
}
}
}
Customize views on ViewPlaceholder.xib
License
Free