StatefulViewController icon indicating copy to clipboard operation
StatefulViewController copied to clipboard

Add instructions to change backing view.

Open kapoorsahil opened this issue 10 years ago • 2 comments

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
}

kapoorsahil avatar Oct 21 '15 14:10 kapoorsahil

image

Try this, it worked fine for me :)

alinekborges avatar Jan 16 '17 12:01 alinekborges

@alinekborges Thanks so much! here's your answer as text (and with some explanation):

  1. Your ViewController already most likely adopts StatefulViewController protocol. Make it also adopt BackingViewProvider protocol like this: open class GenericCollectionVC: UIViewController, StatefulViewController, BackingViewProvider {
  2. 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 }
  3. Note that I set self.collectionView to be the parent view of my StatefulViews, but you can use any view there

drpawelo avatar Aug 22 '17 16:08 drpawelo