I have couple of problems with my UITableView
.
When I add a UITableview
on my page, by default it brings up some fixed number of rows, even though I set number of rows in section as 1
. All the rows appear except the first row, and all are empty rows. So, I want to hide all the empty rows in the UItableview
.
Based on the non-empty rows, I want to change the height of my UItableView
.
NEW ANSWER
In Swift 2.2, 3.0 and onwards, do the following:
tableView.tableFooterView = UIView()
OLD ANSWER BELOW. KEPT FOR POSTERITY.
If you must use UITableViewStylePlain
, and you don't use a footerView for anything else, you can use the following semi-dirty solution if you have ARC enabled.:
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { UIView *view = [[UIView alloc] init]; return view; }
If you have ARC disabled, use the following:
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { UIView *view = [[[UIView alloc] init] autorelease]; return view; }
This creates an invisible footerView, that appears immediately after the last data-filled cell.
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