Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 滚动视图上的导航栏不在顶部_Ios_Swift_Swift3_Uiscrollview_Uinavigationbar - Fatal编程技术网

Ios 滚动视图上的导航栏不在顶部

Ios 滚动视图上的导航栏不在顶部,ios,swift,swift3,uiscrollview,uinavigationbar,Ios,Swift,Swift3,Uiscrollview,Uinavigationbar,我正在做一个项目,在一个滚动视图上有多个视图。 我可以水平滚动浏览它们。很好用! 但是我在scrollview中添加的每个视图中的导航栏都有问题。 从屏幕截图可以看出,它们在上面,但是顶部的导航栏并没有从顶部填充所有内容。 这里有空白,我不想要。我希望这个空间与导航栏的蓝色相同 现在我的问题是,我怎样才能做到这一点 我在scrollview中添加了带有以下代码的视图: class ScrollViewController: UIViewController { @IBOutlet weak v

我正在做一个项目,在一个滚动视图上有多个视图。 我可以水平滚动浏览它们。很好用! 但是我在scrollview中添加的每个视图中的导航栏都有问题。 从屏幕截图可以看出,它们在上面,但是顶部的导航栏并没有从顶部填充所有内容。 这里有空白,我不想要。我希望这个空间与导航栏的蓝色相同

现在我的问题是,我怎样才能做到这一点

我在scrollview中添加了带有以下代码的视图:

class ScrollViewController: UIViewController {

@IBOutlet weak var scrollView: UIScrollView!
override func viewDidLoad() {
    super.viewDidLoad()

    let profilView = self.storyboard?.instantiateViewController(withIdentifier: "profilController") as! UIViewController
    self.addChildViewController(profilView)
    self.scrollView.addSubview(profilView.view)
    profilView.didMove(toParentViewController: self)
    profilView.view.frame = scrollView.bounds

    let testViewTwo = self.storyboard?.instantiateViewController(withIdentifier: "chatController") as! UIViewController
    self.addChildViewController(testViewTwo)
    self.scrollView.addSubview(testViewTwo.view)
    testViewTwo.didMove(toParentViewController: self)
    testViewTwo.view.frame = scrollView.bounds

    var frame:CGRect = testViewTwo.view.frame
    frame.origin.x = self.view.frame.width
    testViewTwo.view.frame = frame

    self.scrollView.contentSize = CGSize(width: self.view.frame.width * 2, height: self.view.frame.height)

    //startposition
    //self.scrollView.contentOffset = CGPoint(x: (self.view.frame.width) * 1, y: self.view.frame.height)
}

谢谢你的帮助

将导航栏高度设置为64,并将其放置在状态栏后面