Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display a placeholder before the tableview cells get displayed?

Tags:

This questions is referencing just before a tableview fetches its data and displays its cells.

I've seen a few apps lately display a rough outline type image of the tableview cells for the brief moments before the populated cells get displayed.

How is this done?

Is a placeholder image used for the entire tableview or are placeholder type images rendered for each cell until the cell is dequeued?

Here are examples from Facebook and the fiverr app fiverr Facebook

like image 395
grabury Avatar asked May 06 '17 04:05

grabury


People also ask

How do you make a tableView cell Unselectable?

To completely prevent selection of the UITableViewCell , have your UITableViewDelegate implement tableView:willSelectRowAtIndexPath: . From that method you can return nil if you do not want the row to be selected. This prevents the row from being selected and tableView:didSelectRowAtIndexPath: from being called.

How to display placeholder in JavaFX Tableview with no rows?

You can set a placeholder to be displayed when the JavaFX TableView has no rows to display. The placeholder must be an instance of the JavaFX Node class, which most (if not all) JavaFX controls are. Thus, you can use an JavaFX ImageView or JavaFX Label as placeholder. Here is an example of using a Label as placeholder in a JavaFX TableView :

How to determine the cell count of a Tableview?

As mentioned, the cell count is determined by the number of visible rows and columns (visible cells). It doesn't matter if there are 1000 data items (rows) in the items list of the TableView.

How does the Tableview handle very large data sets?

As the user scrolls through the data in the data set displayed in the TableView, the already created cell rendering objects are reused to display the rows that become visible. This way, the TableView can handle very large data sets with less memory overhead from cell rendering objects.

What is the difference between a Tableview and a viewcell?

The root element under the TableView is the TableRoot, and there is a TableSection immediately underneath the TableRoot. The ViewCell is defined directly under the TableSection, and a StackLayout is used to manage the layout of the custom cell, although any layout could be used here.


2 Answers

Create a separate UITableViewCell class where the content of the cell is a UIImageView that has some kind of placeholder image of what your cells will look like. Populate the UITableView with those cells while your background request is being made. When the request completes, start a table update in which you remove all the placeholder cells, then insert all the "real" cells.

like image 171
Scott Thompson Avatar answered Oct 03 '22 18:10

Scott Thompson


According to me it would be better to add backgroundView to tableView.

write:

while searching /fetching data:

if results.count == 0{     tableview.backroundView = emptyBlurView     } 

once data is received so before reload :

 tableview.backroundView = nil 
like image 36
ankit Avatar answered Oct 03 '22 17:10

ankit