ScrollView 和导航栏 ios9

ScrollView and Navigation Bar ios9

我在导航控制器中嵌入了一个视图控制器(名为 View2)。 在这个视图中,我有一个覆盖所有视图(包括导航栏)的 ScrollView。

此视图控制器通过调用从另一个视图呈现:

let view2 = self.storyboard?.instantiateViewControllerWithIdentifier("View2") as! View2
let modalStyle: UIModalTransitionStyle = UIModalTransitionStyle.CrossDissolve
let nav: UINavigationController = UINavigationController.init(rootViewController: view2)
nav.modalTransitionStyle = modalStyle
self.presentViewController(nav, animated: true, completion: nil)

在我的View2中,我将导航栏调整为半透明:

navigationController?.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: UIBarMetrics.Default)
navigationController?.navigationBar.shadowImage = UIImage()
navigationController?.navigationBar.translucent = true

但是有一个问题,当View2出现时,scrollview在导航栏下方开始。我必须在滚动视图上点击一次才能看到它在屏幕顶部的导航栏上方自动调整。

有解决办法吗?

我希望滚动视图出现在屏幕顶部,在半透明的导航栏上方。

感谢您的反馈,

托马斯

您是否尝试在您的视图控制器上设置 automaticallyAdjustsScrollViewInsets = false

另一种选择是取消选中 "Extend Edges" 中视图控制器的属性检查器中的选项 "Under Top Bar"。

希望这对您有所帮助。