Tab bar covers UITableView's last cell

后端 未结 12 1869
挽巷
挽巷 2020-12-16 01:18

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 vie

相关标签:
12条回答
  • 2020-12-16 01:41

    This did the trick here (within Interface Builder):

    TableView above TabBar

    0 讨论(0)
  • 2020-12-16 01:46

    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!

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2020-12-16 01:51

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

    0 讨论(0)
  • 2020-12-16 01:51

    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)];
    
    0 讨论(0)
  • 2020-12-16 01:52

    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 rect = self.navigationController?.tabBarController?.tabBar.frame {
        let y = rect.size.height
        tableView.contentInset = UIEdgeInsetsMake( 0, 0, y, 0)
        tableView.scrollIndicatorInsets = UIEdgeInsetsMake(0, 0, y, 0)
    }
    
    0 讨论(0)
提交回复
热议问题