StatefulViewController
StatefulViewController copied to clipboard
Add instructions to change backing view.
I want a subview of my controller to change loading state. Is it possible?
I added this to my controller but doesn't work
var backingView: UIView {
return contentView
}

Try this, it worked fine for me :)
@alinekborges Thanks so much! here's your answer as text (and with some explanation):
- Your ViewController already most likely adopts StatefulViewController protocol. Make it also adopt BackingViewProvider protocol like this:
open class GenericCollectionVC: UIViewController, StatefulViewController, BackingViewProvider { - then in your code re-define what view should hold all the StatefulViews (emptyView, loadingView, errorView) by defining backingView variable
public var backingView: UIView { return self.collectionView } - Note that I set self.collectionView to be the parent view of my StatefulViews, but you can use any view there