Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternate text for empty UITableView?

I am using a UITableView to display some data which the user can filter. If a certain (perfectly "legal") combination is selected, all data is filtered out (hidden). I would like to display some text stating that no results were found and to please modify your filters.

Does anything trigger when this occurs that I can hook in to?

Or will I have to manually check for an empty data set and create a custom view to display my text? (I was thinking of creating a blank cell and using that footer? Hoping for something more elegant...)

I found a similar question, but the solution is not what I am looking for: Handling empty UITableView in UITableViewController

Also, I have an Android programming background and use this exact feature frequently, I would be surprised if Apple didn't do this as well!

like image 343
Joe Masilotti Avatar asked Aug 29 '11 15:08

Joe Masilotti


1 Answers

Put a custom view with your error text message behind the table. Then when there is no data to be displayed set table.alpha=0.0 (or table.hidden=YES), while when you have this data available set table.alpha=1.0 (or table.hidden=NO). You can do the control on the "OK" button (or equivalent) of the filter.

like image 109
viggio24 Avatar answered Oct 13 '22 21:10

viggio24