aschuch / StatefulViewController

Placeholder views based on content, loading, error or empty states
MIT License
2.14k stars 149 forks source link

Issue when the view controller's view is tableView/collectionView #31

Closed MarvinNazari closed 7 years ago

MarvinNazari commented 8 years ago

Hi Awesome project, but we have an issue when the view of the UIViewController is an UITableview (example below)

class VC: UIViewController {
    override func loadView() {
        view = UITableView()
    }
}

so it adds the loadingView/emptyView inside of the tableView

aschuch commented 8 years ago

The default implementation of the StatefulViewController protocol uses the UIViewController's view as its backingView. I usually just add the UITableView to the view so I haven't personally run into this issue.

You can, however, always override the backingView property and return a custom view where the placeholder views should be added.

AnthonyMDev commented 7 years ago

This might be able to be fixed by using the ContainerViewStateMachine implementation from PR #29 as the default implementation for all view controllers.

It seems that, in order to handle odd little corner cases like this, it is safer to use a privately managed container view, rather than relying on the view of the UIViewController.

AnthonyMDev commented 7 years ago

In fact, rather than adding the views for the states to the backingView it may be better to do a transition FROM the view of the controller to our state view and then back.

aschuch commented 7 years ago

I've pushed some changes to master that allow for better support of UITableViewController and UICollectionViewController (thanks @AnthonyMDev). @MarvinNazari Please take a look and report any issues. Thanks! ✌️