Swift 3 - Tableview显示标签和导航栏后面尽管有其他尝试

时间:2017-03-14 00:50:28

标签: ios swift swift3

我正在使用Swift 3并为iPhone 7开发。

当用户点击按钮时,我将TableViewController实例化为:

// Instantiate the Table View Controller that the info will be on
let detailVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "dvc") as! ResultsVC

detailVC.view.backgroundColor = UIColor.white

让父视图控制器能够呈现它。

然而,问题是它出现在标签栏和导航栏后面。

enter image description here

尽管尝试使用ResultsVC viewDidLoad方法设置这些内容:

// 49 is the height for tab bar, 64 is the height for nav bar
let adjustForTabbarInsets: UIEdgeInsets = UIEdgeInsetsMake(49, 0, 64, 0);        
self.tableView.contentInset = adjustForTabbarInsets;
self.tableView.scrollIndicatorInsets = adjustForTabbarInsets;

OR

self.edgesForExtendedLayout = []
self.extendedLayoutIncludesOpaqueBars = false
self.automaticallyAdjustsScrollViewInsets = false

我甚至进入了Xcode,在故事板中单击了相关的视图控制器并取消选中:

enter image description here

非常感谢任何帮助。

2 个答案:

答案 0 :(得分:0)

您可以尝试设置约束。由于iOS9和iOS10使用Tab Bar的49个点和导航栏的64个点,因此我们可以使用常量设置约束:

override func viewDidLoad() {

    collectionView.translatesAutoresizingMaskIntoConstraints = false
    collectionView.topAnchor.constraint(equalTo: view.topAnchor, constant: 64).isActive = true
    collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -49).isActive = true
    collectionView.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true
    collectionView.rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true
}

答案 1 :(得分:0)

尝试手动将视图置于前面

parentView.bringSubview(toFront: coveredView)