我正在使用pagevew控制器来实现抽屉的功能。每个工作正常,但第一次加载视图时,它会留下状态栏的空间并从状态栏开始。我需要显示y = 0
的视图private func setupPageViewController() {
pageViewController = UIPageViewController(transitionStyle: UIPageViewControllerTransitionStyle.Scroll, navigationOrientation: UIPageViewControllerNavigationOrientation.Horizontal, options: nil)
pageViewController.dataSource = self
pageViewController.delegate = self
pageViewController.setViewControllers([stackPageVC[stackStartLocation]], direction: UIPageViewControllerNavigationDirection.Forward, animated: true, completion: nil)
var pageViewControllerY: CGFloat = 0
var pageViewControllerH: CGFloat = 0
if navigationBarShouldNotExist {
pageViewControllerY = 0
pageViewControllerH = Constants.ScreenHeight
} else {
pageViewControllerY = 0
pageViewControllerH = Constants.ScreenHeightWithoutStatusBar
}
pageViewController.view.frame = CGRect(x: 0, y: pageViewControllerY, width: Constants.ScreenWidth, height: pageViewControllerH)
pageViewController.view.backgroundColor = UIColor.clearColor()
addChildViewController(pageViewController)
view.addSubview(pageViewController.view)
pageViewController.didMoveToParentViewController(self)
}
我尝试使用
for v: UIView in pageViewController.view.subviews {
if (v is UIScrollView) {
let scroll = v as! UIScrollView
scroll.setContentOffset(CGPointMake(0, 0), animated: false)
print("----")
}
}
对于抽屉功能我正在使用此库drawer
有一点是,如果我触摸屏幕上的任何地方,那么它会恢复正常
答案 0 :(得分:1)
只需选择放置pageviewcontroller的故事板,在右侧有一个选项UnderTopBar只需取消选择该选项即可。你会得到解决方案。或者你可能只是设置了toplayout约束,所以设置从toplayout到视图