简体   繁体   中英

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];

在此输入图像描述

If I change the tableview frame to

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

在此输入图像描述

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

Thank you very much.

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.

Set the translucent property to NO

// In init or viewDidLoad of tab bar controller
self.tabBar.translucent = NO;

Now the tab bar should resize the table view.

The translucent property is available iOS 7 and up.

//在viewDidLoad()中,以下行为我工作

self.edgesForExtendedLayout = UIRectEdge.None self.navigationController?.navigationBar.translucent = false self.tabBarController?.tabBar.translucent = false

You have 2 options:

First

self.tableView.contentInset.bottom = self.tabBarController?.tabBar.frame.height ?? 0

This will do the trick and save the transparent property of the tab bar.


Second In design view just uncheck the option Under Bottom Bars , But put in your mind the tab bar will look like solid color (no thing behind it).

在此输入图像描述

在此输入图像描述

Swift :

self.tabBar.isTranslucent = false

Note: @Eric Amorde answers converted to Swift.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM