iOS7 table view embedded in tab bar doesn't display last cell

后端 未结 5 834
花落未央
花落未央 2021-01-02 10:10

In my storyboard, I have a View controller (embedded in a navigation controller). Inside the view controller I have a tab bar controller, and inside a tab a table view contr

相关标签:
5条回答
  • 2021-01-02 10:24

    I had the same problem, and the up-voted answers did not solve it. See my answer to a similar question, Tab Bar covers TableView cells in iOS7.

    I solved the issue by manually setting the table view's frame in the table view controller's viewWillAppear: method (as suggested by Matt Quiros) to the height of the screen - (status bar height + nav bar height + tab bar height).

    - (void)viewWillAppear:(BOOL)animated
    {
        [super viewWillAppear:animated];
    
        // Adjust height of tableview (does not resize correctly in iOS 7)
        CGRect tableViewFrame = self.tableView.frame;
        tableViewFrame.size.height = [self heightForTableView];
        self.tableView.frame = tableViewFrame;
    }
    
    - (CGFloat)heightForTableView
    {
        return CGRectGetHeight([[UIScreen mainScreen] bounds]) -
               (CGRectGetHeight([[UIApplication sharedApplication] statusBarFrame]) +
                CGRectGetHeight(self.navigationController.navigationBar.frame) +
                CGRectGetHeight(self.tabBarController.tabBar.frame));
    }
    

    If anyone finds a better solution to this problem, please share!

    0 讨论(0)
  • 2021-01-02 10:25

    This, as said, will work perfectly. I've just tested it.

    self.tabBar.translucent = NO;
    
    0 讨论(0)
  • 2021-01-02 10:36

    Try setting your tabbar translucent property.

    self.navigationController.navigationBar.translucent= NO; // Set transparency to no and

    self.tabBar.translucent= NO; //Set this property so that the tab bar will not be transparent

    0 讨论(0)
  • 2021-01-02 10:36

    The accepted and upvoted answers don't work for my setup:

    UITabBarController -> UINavigationController -> UIViewController -> UITableView

    My app's root view controller is a UITabBarController. Every tab is a UINavigationController, and in one tab, the navigation controller's root is a UIViewController with a table view as the main view.

    So here's what worked for me: When alloc-initing the UITableView, I compute for the height and set it in the table view's frame. The general formula is screen height - (status bar height + nav bar height + tab bar height).

    0 讨论(0)
  • 2021-01-02 10:38

    I think it has to do with automaticallyAdjustsScrollViewInsets not being applied (or applied correctly) due to the nested structure of your view controller hierarchy.

    Try and copy your table into a new UIViewController and make sure the checkmark in the UIViewController's identity inspector called "Adjust Scroll View Insets" is turned on.

    0 讨论(0)
提交回复
热议问题