Ios Swift 3-表视图显示在选项卡和导航栏后面,尽管有其他尝试
我正在使用Swift 3并为iPhone 7开发 当用户单击按钮时,我实例化一个Ios Swift 3-表视图显示在选项卡和导航栏后面,尽管有其他尝试,ios,swift,swift3,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
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
并让父视图控制器能够显示它
然而,问题是它出现在标签和导航栏后面
尽管尝试在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;
或
我甚至进入了Xcode,在情节提要中单击了有问题的视图控制器并取消选中:
任何帮助都将不胜感激。您可以尝试设置约束。由于iOS9和iOS10使用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
}
尝试手动将视图移到前面
parentView.bringSubview(toFront: coveredView)
请发布您展示新视图控制器的代码。嗯,这似乎对我不起作用…还没有。我使用了你的代码,现在它似乎不再是标签和导航栏后面的视图,而是完全黑色的视图。
parentView.bringSubview(toFront: coveredView)