20
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, [UIScreen mainScreen].bounds.size.height ) style:UITableViewStylePlain];

在此处输入图像描述

如果我将 tableview 框架更改为

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

在此处输入图像描述

滚动条会留下空白,我不喜欢它。我该如何解决这个问题?

非常感谢你。

4

5 回答 5

50

您可以尝试设置该contentInset表视图的。在 iOS 7 中有一个topLayoutGuideand bottomLayoutGuide(这是你想要的)。里面应该基本上给你底栏的高度UITabBarControllerbottomLayoutGuide

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

应该做的伎俩。

于 2013-11-01T03:45:25.383 回答
29

将半透明属性设置为NO

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

现在标签栏应该调整表格视图的大小。

translucent属性适用于 iOS 7 及更高版本。

于 2013-11-01T03:47:20.077 回答
4

您有 2 个选项:

第一的

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

这将解决问题并保存栏的透明属性。tab


其次 在设计视图中,只需取消选中该选项Under Bottom Bars,但请记住,tab bar它将看起来像纯色(后面没有任何东西)。

在此处输入图像描述

在此处输入图像描述

于 2017-04-19T07:58:10.407 回答
1

// 在 vi​​ewDidLoad() 中,以下几行对我有用

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

于 2016-11-19T10:23:15.473 回答
1

斯威夫特

self.tabBar.isTranslucent = false

注意:@Eric Amorde 答案转换为 Swift。

于 2018-02-27T12:25:54.590 回答