• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ios - 最后一个单元格在底部被我的 UITabBar 切断

[复制链接]
菜鸟教程小白 发表于 2022-12-12 09:57:55 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

我有一个带有 UITabBar 的主 viewController A。我的问题是当我滚动到最后一个单元格并在 UITableView 中单击单元格并转到 viewController B 之后,当我回到我的 viewController A,我的最后一个单元格在底部被截断,我可以滚动显示该单元格的所有内容。但默认情况下,底部 UITableView 与上次不同。

当我启动 viewController B 我在 VCB "viewWillAppear"中隐藏我的 UITabBar 代码:

- (void)hideTabBar {

    UITabBar *tabBar = self.tabBarController.tabBar;
    UIView *parent = tabBar.superview;
    UIView *content = [parent.subviews objectAtIndex:0];
    UIView *window = parent.superview;
    [UIView animateWithDuration:0.3
                     animations:^{
                         CGRect tabFrame = tabBar.frame;
                         tabFrame.origin.y = CGRectGetMaxY(window.bounds);
                         tabBar.frame = tabFrame;
                         content.frame = window.bounds;
                     }];
}

当我回到我的 viewController A 时,我会在 VCB "viewWillDisappear"中显示我的 UITabBar 代码:

- (void)showTabBar {

    UITabBar *tabBar = self._tab;
    UIView *parent = tabBar.superview; 
    UIView *content = [parent.subviews objectAtIndex:0];
    UIView *window = parent.superview;

    [UIView animateWithDuration:0.3
                     animations:^{
                         CGRect tabFrame = tabBar.frame;
                         tabFrame.origin.y = CGRectGetMaxY(window.bounds) - CGRectGetHeight(tabBar.frame);
                         tabBar.frame = tabFrame;

                         CGRect contentFrame = content.frame;
                         contentFrame.size.height -= tabFrame.size.height;
                     }];
}

我在 iOS 6 中遇到了同样的问题,但滚动条不允许滚动到底部,并且最后一个单元格总是被切断。

在我的 viewController A in "viewWillAppear"我做:

if ([[UIDevice currentDevice].systemVersion hasPrefix"7"]) {
    [self._tabBarControllerArticle.tabBar setTranslucent:NO];    
}
  • 点击之前(图 1)
  • 当我回来时(图 2)

Before when I clicked

When I come back

感谢您提前提供所有答案!!!



Best Answer-推荐答案


另一种方法是将 tabBar 的 translucent 属性设置为 NO 像这样

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

假设您使用的是 iOS7,这应该在 self.tabBar

上方调整您的 UITableView

关于ios - 最后一个单元格在底部被我的 UITabBar 切断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23778959/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap