I'm using below code to create a larger and more clean look on a plain (not grouped) UITableView. It's working fine unless i have a empty table then the cell's height sets to normal height. I have the standard Separatorstyle (the gray lines) so it looks rly bad if it's empty.
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
{
return 75;
}
Any idea how to fix this?
EDIT:
Found an even better solution where i dont even display the lines if the table is "Empty" and displays guide text instead.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if ([dataArray count] == 0) {
[theTableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
[pleaseAddStuffText setHidden:NO];
} else {
[theTableView setSeparatorStyle:UITableViewCellSeparatorStyleSingleLine];
[pleaseAddStuffText setHidden:YES];
}
return [dataArray count];
}
You should be able to force a row height at all times by setting rowHeight, even if the row count is 0.
self.tableView.rowHeight = 75.0;
You can also set it in IB.
heightForRowAtIndexPath seems to only be called if a cell is being set up in cellForRowAtIndexPath, whereas this is a property of the tableview and is always present.
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