Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Align table cells to bottom in IOS5

I have a UITableViewController with 3 static cells on it in one section. I'd like to align the whole table to the bottom, not to the top. I tried to set several settings in Xcode bit could not solve it. How can I do this?

UPDATE: so, this is the alignment I want, the cells are in red: enter image description here

Thanks

like image 593
Tom Avatar asked Feb 21 '23 19:02

Tom


2 Answers

If you manually compute the height of your rows, you can set the table view's contentInset (inherited from UIScrollView) to push the rows down. You'll have to manually update the inset if you change the table rows. For example, if all of your rows are the same height:

CGFloat totalRowHeight = [self.tableView numberOfRowsInSection:0] * self.tableView.rowHeight;
CGFloat topInset = MAX(0, self.tableView.bounds.size.height - totalRowHeight);
self.tableView.contentInset = UIEdgeInsetsMake(topInset, 0, 0, 0);
like image 179
rob mayoff Avatar answered Feb 28 '23 05:02

rob mayoff


Use a large positive value for the table view's top content inset. This will push the cells down as far as you specify.

like image 37
Mark Adams Avatar answered Feb 28 '23 05:02

Mark Adams