1
我使用pagevew控制器的抽屜功能。每一件事情都可以正常工作,但第一次當視圖加載時,它會留下狀態欄的空間並在狀態欄下開始。我需要從Y顯示視圖= 0uipageViewController沒有加載視圖與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
有一點是,如果我在屏幕上的任何地方觸摸,然後去正常
只是選擇了放置pageviewcontroller的故事板和右側有一個選項UnderTopBar只需取消選擇該選項。你會得到解決方案。或者你可能只是設置約束與toplayout,以便設置從顯示以查看 –