I am loading a content into UITableView dynamically. If there is data the table needs to display the data. If there is no data the table should display a plain page. But in my application the table displays the plain page with two separator lines. i need to remove this separator line and display a plain white page. Please Suggest?
Any help would be appreciated!
If you provide a view to the footer then the separators between the empty rows will disappear.
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1, 1)];
myTableView.tableFooterView = view;
You could check for the empty case if your datasource is empty add a placeholder view on top of the tableview. If they are not empty, remove the placeholder view.
A plain UITableView
will always display separator lines even if it is empty. You might notice that if you have a list with only one or two rows, there are still separator lines visible. This is the default behaviour and should not be overridden unless you have a really good reason.
I am guessing you see only two separator lines because your rows are very tall?
If you do really need to remove the separator lines then set the separatorStyle
property on your table view to UITableViewCellSeparatorStyleNone
. Take note that this will affect all rows. So if you still want separators for the rows that do exists, then you must draw these separator lines in your own UITableViewCell
objects.
It can be simplified to a single line, using @bbarnhart solution:
myTableView.tableFooterView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With