【问题标题】:Last cell is cut off at the bottom with my UITabBar最后一个单元格在底部被我的 UITabBar 切断
【发布时间】:2014-05-21 09:19:01
【问题描述】:

我有一个主要的viewController A 和一个UITabBar。我的问题是,当我滚动到最后一个单元格时,当我通过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 在“viewWillAppear”中,我这样做:

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

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

【问题讨论】:

标签: ios objective-c uitableview uitabbarcontroller uitabbar


【解决方案1】:

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

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

假设您使用的是 iOS7,这应该将您的 UITableView 调整为略高于 self.tabBar

【讨论】:

  • 谢谢,但这不是我的问题
【解决方案2】:

单击发生问题的 tableViewController,转到 Attributes Inspector,向下滚动并取消选中“Under Bottom Bars”框。

question 的选定答案帮助了我。

【讨论】:

    【解决方案3】:

    您错过了将框架分配回您的视图。查看更新后的代码。

    - (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;
    
                             //YOU MISSED TO ADD BELOW LINE....
                             content.frame = contentFrame;
                         }];
    }
    

    【讨论】:

    • 谢谢,但是有了这条线,我的 UITabBar 正上方有一个黑条,但显然单元格很好,但就在黑条后面...就在 IOS 7 和 IOS 6 上,我有相同的行为较早的 IOS 7
    • 如何删除这个黑条而不隐藏我的 UITabBar ? @Apurv
    猜你喜欢
    • 1970-01-01
    • 2015-01-08
    • 2017-11-22
    • 2019-12-21
    • 1970-01-01
    • 1970-01-01
    • 2014-09-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多