UITableView is under the TabBar

前端 未结 7 2048
花落未央
花落未央 2021-01-24 20:57

I have a custom UITableView with custom cells (70px height for each cell).

I have also a 49px UITabBar, but it\'s hides the tableView.

相关标签:
7条回答
  • 2021-01-24 21:25

    If you changed self.hidesBottomBarWhenPushed=true in previous view controller, then make sure to change it to self.hidesBottomBarWhenPushed=false inside override func prepare(for segue: UIStoryboardSegue, sender: Any?) {}

    0 讨论(0)
  • 2021-01-24 21:26

    Try this

    self.commentsTableView.contentInset = UIEdgeInsetsMake(49, 0, 0, 0)
    self.commentsTableView.setContentOffset(CGPoint.init(x: 0, y: -49), animated: false)
    
    0 讨论(0)
  • 2021-01-24 21:31

    You should config the corresponding view controller with following code to remove the edges extend (It defaults to UIRectEdgeAll)

    edgesForExtendedLayout = []
    
    0 讨论(0)
  • 2021-01-24 21:32

    I ran into this issue when dealing with a table view in a navigation controller that did not have translucent bars. I performed a setup similar to the following:

    override func viewDidLoad() {
        super.viewDidLoad()
    
        // Without this there is some extra fast inertia when slowly
        // scrolling to the top.
        extendedLayoutIncludesOpaqueBars = true
    
        // Don't extend the tableview past the bottom bar, though.
        // If we do then a tab bar or bottom nav bar will block
        // content.
        edgesForExtendedLayout = [.top, .left, .right]
    }
    

    However, I later discovered that a couple of checkboxes were unchecked in a storyboard higher up the hierarchy. Specifically these two:

    Checking these two boxes removed the need to care about the content insets and the layout extending behavior in that view controller

    0 讨论(0)
  • 2021-01-24 21:40

    i don't know what you did exactly, but try like this:

    self.edgesForExtendedLayout = UIRectEdgeAll;
    self.tableview.contentInset = UIEdgeInsetsMake(0.0f, 0.0f, CGRectGetHeight(self.tabBarController.tabBar.frame), 0.0f);
    

    I hope, this will work.

    0 讨论(0)
  • 2021-01-24 21:40

    This did the trick for me in Swift 3.

    if let tabBarController = tabBarController {
        self.tableView.contentInset = UIEdgeInsetsMake(0.0, 0.0, tabBarController.tabBar.frame.height, 0.0);
    }
    
    0 讨论(0)
提交回复
热议问题