标签栏覆盖 UITableView 的最后一个单元格

发布于 2024-09-13 13:43:55 字数 115 浏览 5 评论 0原文

我正在开发一个基于选项卡栏应用程序预设的应用程序。在其中一个选项卡中,我有一个显示大量数据的表格视图,但是当我滚动到底部时,表格视图中最后一个单元格的一半被选项卡栏覆盖。

有人有解决这个问题的办法吗?

I'm developing an application based on the Tab Bar application preset. In one of the tabs I have a table view showing a lot of data, but half the last cell in the table view is covered by the tab bar when I've scrolled to the bottom.

Anyone has a solution to this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(12

星星的軌跡 2024-09-20 13:43:55

添加页脚空间对我有用:

//this prevent the tabbar to cover the tableview space
UIView *footer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1, 90)];
footer.backgroundColor = [UIColor clearColor];
myTableView.tableFooterView = footer;

Adding a footer space worked for me:

//this prevent the tabbar to cover the tableview space
UIView *footer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1, 90)];
footer.backgroundColor = [UIColor clearColor];
myTableView.tableFooterView = footer;
2024-09-20 13:43:55

这在这里完成了技巧(在 Interface Builder 中):

TableView above TabBar

This did the trick here (within Interface Builder):

TableView above TabBar

秋心╮凉 2024-09-20 13:43:55

对此有几种解决方案。

1.) 假设您使用半透明工具栏,则必须使工具栏不透明。

2.) 如果您使用 StoryBoard 并且将 TableView 放入 ViewController 中,假设它是 ViewController 而不是 TableViewController。

3.) 您可以手动添加填充/间距。

if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
{
    self.edgesForExtendedLayout = UIRectEdgeNone;
    self.extendedLayoutIncludesOpaqueBars = YES;
    self.automaticallyAdjustsScrollViewInsets = NO;
}

UIEdgeInsets insets = UIEdgeInsetsMake (0,sizeOfTableView - sizeOfTabBar, 0, 0);
self.tableView.contentInset = inset;
self.tableView.scrollIndicatorInsets = inset;

希望这有帮助&快乐编码!

There are a couple of solutions for this.

1.) Assuming that you are using translucent tool bars, you have to make the tool bars opaque.

2.) If you are using StoryBoard and you are putting a TableView inside your ViewController, assuming it's a ViewController and not a TableViewController.

3.) You can manually add padding/spacing.

if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
{
    self.edgesForExtendedLayout = UIRectEdgeNone;
    self.extendedLayoutIncludesOpaqueBars = YES;
    self.automaticallyAdjustsScrollViewInsets = NO;
}

or

UIEdgeInsets insets = UIEdgeInsetsMake (0,sizeOfTableView - sizeOfTabBar, 0, 0);
self.tableView.contentInset = inset;
self.tableView.scrollIndicatorInsets = inset;

Hope this helps & Happy coding!

偏闹i 2024-09-20 13:43:55

查看选项卡栏的大小,并相应地调整表格视图的大小。阅读有关框架属性的文档,如果您将 IB 用于此目的,则 IB 允许您设置事物的大小等。

Look at the size of the tab bar, and adjust the size of your table view accordingly. Read the docs on the frame property, IB lets you set the size of things if you're using IB for this purpose, etc.

反目相谮 2024-09-20 13:43:55

真正的答案:

我遇到了这个问题,最终来到这里......所以即使这是旧的,这就是我解决这个问题的方法:

我有一个 UITabBar 控制器,其中一个选项卡是 UIViewController,并且它添加了一行:

[self.view addSubview:navController.view];

这是错误..即使代码有效,这个概念也是错误的(至少在我的情况下),navController应该作为选项卡之一直接链接在UITabBar中......

那么,什么是真正的答案是什么?

您一定是错误地实现了导航控制器。正如我所解释的,我有这个问题,还有这个人 ...

REAL ANSWER:

I had this problem, and ended up here ... So even if this is old, here is how I solved this issue:

I had a UITabBar controller with one tab being a UIViewController, and it had a single added line:

[self.view addSubview:navController.view];

This is wrong .. Even if the code worked, the concept is wrong (at least in my case), the navController should be directly linked in the UITabBar as one of the tabs...

So, what's the real answer?

You must have implemented the navigation controller incorrectly. As proof is that I had this issue, as I explained, and also This Guy...

断念 2024-09-20 13:43:55

Swift 3:

这对我来说非常有效。此代码不仅停止显示选项卡栏后面的最后一个单元格,而且还向上推滚动指示器。将代码放入您的 viewDidLoad() 中:

if let bottomInset = navigationController?.tabBarController?.tabBar.frame.size.height {
    tableView.contentInset.bottom = bottomInset
    tableView.scrollIndicatorInsets.bottom = bottomInset
}

或者您可以这样做:

override func viewDidLayoutSubviews() {
    super.viewDidLayoutSubviews()
    tableView.contentInset.bottom = view.safeAreaInsets.bottom
    tableView.scrollIndicatorInsets.bottom = view.safeAreaInsets.bottom
}

Swift 3:

This is what worked perfectly for me. This code not only stop the last cell showing behind the tab bar, but also pushes up the scroll indicator. Put the code in your viewDidLoad():

if let bottomInset = navigationController?.tabBarController?.tabBar.frame.size.height {
    tableView.contentInset.bottom = bottomInset
    tableView.scrollIndicatorInsets.bottom = bottomInset
}

or you could do this:

override func viewDidLayoutSubviews() {
    super.viewDidLayoutSubviews()
    tableView.contentInset.bottom = view.safeAreaInsets.bottom
    tableView.scrollIndicatorInsets.bottom = view.safeAreaInsets.bottom
}
物价感观 2024-09-20 13:43:55

I've found the only solution to this is to add a padded footer for the tableview:

http://www.iphonedevsdk.com/forum/iphone-sdk-development/18180-resizing-uitableview-programatically.html

柏拉图鍀咏恒 2024-09-20 13:43:55

我刚刚通过添加常数来解决这个问题...硬编码...找到适合您的阈值怎么样?

I just solved this problem by adding constant number... hard coding... How about finding threshold value fit to you?

把回忆走一遍 2024-09-20 13:43:55

选择您拥有 tableview 的视图,打开属性检查器,在 Simulated Metrics 部分中,为 Bottom Bar 项目选择 Tab Bar

然后,XCode 将更新您的视图,为 TabBar 保留空间。所以你的tableview不会被覆盖。

Select the view where you have your tableview, open attribute inspector, in Simulated Metrics section, select Tab Bar for Bottom Bar item.

Then XCode would update your view, reserving space for TabBar. So your tableview would not be covered.

柠檬 2024-09-20 13:43:55

对我来说,只是 UIViewController 中的表视图没有任何约束,一旦我固定到视图的边缘,它就会自行修复。

For me it was just that the table view in UIViewController didn't have any constraints, once I pinned in to the edges of the view it fixed itself.

你没皮卡萌 2024-09-20 13:43:55

SWIFT

我一直遇到这个问题,当我将 UITableViewController 嵌入到 UITabBarController 中时,当完全向下滚动时,最后一个单元格(或底部或大单元格)将保留在 TabBar 下方。经过一天的尝试各种代码和解决方法不起作用后,我只是将 UITableViewController 重新嵌入到导航控制器中,然后将它们嵌入到 TabBar 控制器中。间距是固定的,表视图现在清除 tabBar。

SWIFT

I had been having this problem where when I embed a UITableViewController into a UITabBarController, the last cell (or the bottom or a large cell) would remain under the TabBar when fully scrolled down. After a day of trying various codes and work arounds which didn't work, I simply re-embeded my UITableViewController into a Navigation Controller which was them embedded into a TabBar Controller. The spacing is fixed and the table view clears the tabBar now.

那伤。 2024-09-20 13:43:55

我认为您有一个自定义选项卡栏,您需要将选项卡栏的高度重置为等于该选项卡栏背景图像的高度。

UITabBar * tabbar = self.tabBar ; 
[tabbar setBackgroundImage:[UIImage imageNamed:@"image.png"]] ; 
[tabbar setFrame:CGRectMake(0, 480 - imageHeight, 320, imageHeight)];

I think you have a custom Tabbar, you need reset the height of Tabbar equal to the height of the background image of this Tabbar.

UITabBar * tabbar = self.tabBar ; 
[tabbar setBackgroundImage:[UIImage imageNamed:@"image.png"]] ; 
[tabbar setFrame:CGRectMake(0, 480 - imageHeight, 320, imageHeight)];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文