aschuch / StatefulViewController

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

Add support for 'UITableViewController' #29

Closed AnthonyMDev closed 7 years ago

AnthonyMDev commented 8 years ago

This works by creating a new ViewStateMachine subclass that manages a container view. The views for each state are added to this container view and this container view is added to the UITableViewController.view. When the state is set to .Content, the container view is removed from its superview, but retained by the state machine.

No public APIs have been broken by this PR and the fix works automatically without any new code having to be implemented by the end user. Documentation for all new public classes, and properties has been provided. The demo project has been updated to use a UITableViewController to demonstrate this. It works exactly as expected in all scenarios.

This PR closes #19.

Please let me know if you have any questions about my implementation.

jaimeagudo commented 7 years ago

Thanks guys, any news on this?

AnthonyMDev commented 7 years ago

I haven't heard anything on this in a while. Hoping to see it pulled in soon though.

I've also suggested a different possible solution in #31 that may solve this issue alongside the issue in that ticket. So that may be a good alternative.

eyeezzi commented 7 years ago

@AnthonyMDev, great work on this PR, It appears this is not getting merged anytime soon (its being 9 months already), so do you know of a way I could use your branch in my podfile?

AnthonyMDev commented 7 years ago

@eyeezzi Thanks. I would suggest you make your own fork and then merge my branch into your fork. You can then have your Podfile use your fork like this.

pod 'StatefulViewController', :git => 'https://github.com/eyeezzi/StatefulViewController.git', :branch => 'master'
aschuch commented 7 years ago

😎 Thanks for the PR. I've incorporated some of your ideas but made a lot of changes to add this workaround directly into the ViewStateMachine. I've also added support for UICollectionViewController. However, since the UITableViewController's view is identical to the UITableViewController's tableView, the placeholder views can always be scrolled. This needs to be addressed inside the UITableViewController subclass if that behaviour is not intended. Please take a look at master to see everything in action!