TableView Showing Behind Tab Bar

2019-01-21 17:36发布

I am updating my app to use iOS 7 and I'm having a problem with a table view. My tab bar is translucent. The problem is when I scroll to the bottom of my table view, part of the last cell is still behind the tab bar. I'd like to have a bit of space between the last cell and the tab bar. I could fix this by using an opaque tab bar instead, but I want to keep it translucent.

enter image description here

10条回答
该账号已被封号
2楼-- · 2019-01-21 17:38

Check the screen shot

enter image description here

Check the under top Bar and Un-checke under Bottom Bar

查看更多
做自己的国王
3楼-- · 2019-01-21 17:42

You need to adjust the height of the table view. Just leave 49px at the bottom, as the tabbar height is 49 px. Adjust the height of table view so that it leaves 49px space below it.

查看更多
狗以群分
4楼-- · 2019-01-21 17:44

Try setting

self.edgesForExtendedLayout = UIRectEdgeNone;
self.extendedLayoutIncludesOpaqueBars = NO;
self.automaticallyAdjustsScrollViewInsets = NO;

Inside the tableview controller

查看更多
等我变得足够好
5楼-- · 2019-01-21 17:45

SWIFT 3

put this inside viewDidLoad of your tableViewController:

self.edgesForExtendedLayout = UIRectEdge()
self.extendedLayoutIncludesOpaqueBars = false
self.automaticallyAdjustsScrollViewInsets = false
查看更多
做自己的国王
6楼-- · 2019-01-21 17:49

If any view shows behind a UITabBar you can grab the bottomLayoutGuide and make adjustments at runtime. What I do is have a BaseViewController that all my view controllers inherit from. Then if the tab bar is visible we adjust the view like so:

import UIKit

class BaseVC: UIViewController {

override func viewDidLoad() {
    super.viewDidLoad()
}

override func viewDidLayoutSubviews() {
    //Ensures that views are not underneath the tab bar
    if tabBarController?.tabBar.hidden == false {
        var viewBounds = self.view.bounds;
        var bottomBarOffset = self.bottomLayoutGuide.length;
        self.view.frame = CGRectMake(0, 0, viewBounds.width, viewBounds.height - bottomBarOffset)
    }
  }
}

Since I don't use storyboards (where you can click a checkbox in IB to fix this problem), this has been the best solution I have found.

查看更多
对你真心纯属浪费
7楼-- · 2019-01-21 17:50

Not to sure I like the solution but it works for me.

With iOS 11 I have no issue, I simply use the following in viewDidLoad():

self.collectionView.bottomAnchor.constraint(self.view.safeAreaLayoutGuide.bottomAnchor).isActive = true

However on iOS 10 I need to hack my way like this:

override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
    let tabBarHeight: CGFloat = (self.parent?.tabBarController?.tabBar.frame.size.height)!

    if #available(iOS 11.0, *) {

    } else {
        self.collectionView.bottomAnchor.constraint(equalTo: self.view.bottomAnchor, constant: -tabBarHeight).isActive = true
    }
 }
查看更多
登录 后发表回答