UITabBar will hide the last cell of the UITableView

jxdwinter picture jxdwinter · Nov 1, 2013 · Viewed 13.7k times · Source
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, [UIScreen mainScreen].bounds.size.height ) style:UITableViewStylePlain];

enter image description here

If I change the tableview frame to

(0.0, 0.0, 320.0, [UIScreen mainScreen].bounds.size.height -49.0)

enter image description here

the scroll bar will leave a blank,I do not like it.How can I fix this?

Thank you very much.

Answer

Dennis picture Dennis · Nov 1, 2013

You could try setting the contentInset of that table view. In iOS 7 there's a topLayoutGuide and bottomLayoutGuide (which is what you want). Inside of a UITabBarController the bottomLayoutGuide should give you the height of the bottom bar basically.

tableView.contentInset = UIEdgeInsetsMake(0, 0, self.bottomLayoutGuide.length, 0);

should do the trick.