iPhone : Hiding empty tables cells in a plain view table

I cant seem to work out how to hide table cells that have no data. In grouped view, you only get a cell per piece of data. Whereas in plain view, it renders the cells to the bottom of the screen. I sure its possible because the world clock does it


Irrespective of the type of table, it'll fill up the space allocated to it in Interface Builder (or whatever frame is assigned, etc. if you're creating it programatically).

What you might want to do is set the background as transparent (using the "Clear Color" option as the Background color in the Interface Builder) and use a custom cell background, which is what I believe the world clock does.

To do this, just implement the background in the table cell returned within the tableView:cellForRowAtIndexPath: method by creating a view and using the setBackgroundView and setSelectedBackgroundView methods on the UITableViewCell appropriately.

To get this World Clock Effect I've set a background image for the UITableView background and put the table background color to clearColor via:

UIImage *image = [UIImage imageNamed:@"background.png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
[imageView setFrame:self.tableView.bounds];
[self.tableView setBackgroundView:imageView];
[imageView release];
[self.tableView setBackgroundColor:[UIColor clearColor]];

To get rid of the separators I've changed the separator style to none via

self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

For the UITableViewCell I set a background color (here: white):

UIView *cellBackgroundView = [[UIView alloc] init];
[cellBackgroundView setBackgroundColor:[UIColor whiteColor]];
[cell setBackgroundView:cellBackgroundView];
[cellBackgroundView release];

Need Your Help

Is there a way to check if Bitmap is empty in .NET?

.net bitmap drawing delphi-prism

I am trying to check on a bitmap object to see if it either set or empty. It seems .NET doesn't have that function. I've looked in MSDN library site and stackoverflow and there is very little menti...

How to part DATE and TIME from DATETIME in MySQL

php mysql sql datetime

I am storing a DATETIME field in a Table. After Storing the value its come like

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.