jxdwinter jxdwinter - 2 months ago 10
iOS Question

iOS7 UITabBar will hide the last cell of the UITableView

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

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.

Comments