nxtbgthng / UITableView-NXEmptyView

An easy way to add empty views to your table view without subclassing anything
Other
205 stars 28 forks source link

NXEmptyView for UITableView

What is this?

... a category that dynamically shows an empty view when there are no entries in your table view.

Behavior

The empty view will be displayed whenever the table view has no cells in any section. Of course only if a view has been set via nxEV_emptyView. Whenever the table view is reloaded or layouted the empty view gets updated.

The frame of the empty view is updated to the bounds of the table view, so make sure it layouts nicely for all the orientations and screen sizes (iPhone 5, yay) that you're targeting.

Bypassing the Empty View

There might be scenarios in which you don't want the empty view to appear. For example when the content of the list has not yet been loaded and you don't want to scream at the user that there's none just because it has not yet been loaded.

In that case you can let your table view datasource implement the UITableViewNXEmptyViewDataSource protocol and return NO in -tableViewShouldBypassNXEmptyView:. Whenever this value changes do a -[UITableView reloadData] to update the empty view.

Install

Via Cocoapods

Add this to your Podfile

pod 'UITableView-NXEmptyView'

In your table view do:

Contribute

Contributions are highly welcomed!

Bonus points for feature branches :sunglasses:

Contributors

License

This code is released under the 3-clause BSD License (aka new BSD License or modified BSD License). The full text is included in the LICENSE file in the root of the repository.