Reputation: 141
I am doing a slide menu using a UITableView
and I have 2 options on the menu and I want to put a button at the bottom like in this image:
I try to do that add a tableFooterView
like that.
UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 500, 320, 70)];
footerView.backgroundColor = [UIColor blackColor];
self.tableView.tableFooterView = footerView;
However, the view appears just after the second cell, but I want it at the bottom.
Thanks for help.
Upvotes: 6
Views: 7480
Reputation: 475
Add a Container View with View Controller from storyboard. You can use autoresizing to set the buttons on right place.
Upvotes: 0
Reputation: 450
No you shouldn't add any empty cells, that's just hacky. If you really need the button to be at the bottom, you should use layoutSubviews to control the frame of the tableView and the footerView.
- (void)layoutSubviews
{
[super layoutSubviews];
self.tableView.frame = // top 80% of the screen
self.footerView.frame = // bottom 20% of the screen
}
Upvotes: 9
Reputation: 9091
You should know that every UITableViewCell
has its height and footer is part of a UITableView
and will appear at the bottom of a UITableView
. If you want to make your UITableView
look like what that image shows, you should make sure that your cells are high enough to make sure that your UITableView
are high enough so that footer will appear at the bottom of UITableView
My suggestion is to add extra "empty" cell(I mean a cell with no content but has a height).
Upvotes: 0